[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] How to wrap an unchecked exception in a businessunchecked exception?
|
Hi Dmitri,
We showed how to do this as one example use in an introsuctory article, "Zen
and the art of AOP" at http://www.linux-mag.com/2004-04/aspects_01.html See
listing four & its explanation.
-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Dmitri Mamrukov
Sent: Friday, April 22, 2005 8:36 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] How to wrap an unchecked exception in a
businessunchecked exception?
Greetings!
A business application may have methods like this:
public void doSomething() throws BusinessException
{
try
{
doLogic();
}
catch (Exception e)
{
throw new BusinessException(e.getMessage());
}
}
That is, any checked exception thrown is wrapped with an unchecked
business exception. So I'd like to aspectize this concern. I've tried
this advice (I've read articles that suggest this way):
Object around() throws BusinessException : operations()
{
try
{
return proceed();
}
catch (Exception e)
{
throw new BusinessException(e.getMessage());
}
}
And modified the above business method:
public void doSomething() throws BusinessException
{
doLogic();
}
However, this does not work since the compiler complains about unhandled
checked exceptions.
I've also tried
declare soft: Exception : operations();
but this wraps checked exceptions in unchecked (run-time) exceptions.
Thanks,
Dmitri
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users