Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] how exception handling works?

> public aspect SocketAspect {
> 
>    pointcut p(): call(* java.net.Socket.connect (..));
> 
>  after(): p() {
>      throw new IOException();
>  }
> }
> 
> What is wrong with this aspect? How can I achieve my aim?

You have to go AROUND the call:

public aspect SocketAspect {

   pointcut p(): call(* java.net.Socket.connect (..));

 void around(): p() {
     try{
        proceed(); //do the original call
     } catch( IOException e) {
        //handle e
     }
 }
}

Eric

--
Eric Bodden
Sable Research Group, McGill University
Montreal, Canada
http://bodden.de




Back to the top