Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Prodution Aspect - Exceptions

Your pointcut picks out Error, but your test throws Exception.  

Your advice is:

   after() throwing (Error e): publicMethodCall() { 

Your test code is:

    public void throwError() throws Exception {
        throw new Exception("Teste");
    }

but it should be:

    public void throwError() {
        throw new Error("Teste");
    }

(This mistake is interesting because I can't think of an easy way to 
check for it. hmm.)

Thanks for the test cases -
Wes

P.S. - It was great that you send a complete test case with explanation
of each file.  You might have gotten a quicker response if you appended
the code to the email (rather than attached in separate files), esp. if
you can reduce it to one file.  Many list readers would have caught the 
mistake by inspection if they looked at the code, which I believe they
would have if it were reduced and inlined.

Hugo Magalhães wrote:
> 
> Hello all!
> 
> I'm learning how to use AspectJ and to do that I'm reading the programming guide.
> In the Production Aspect chapter there is an example with exceptions that I've changed to try to write the log to a text file, but unfortunaly that doesn't
> seem to work. Can you tell me what I'm doing wrong? (The source and the build file are in attachment)
> 
> Files:
> Log -> Does the Log to a file
> Log Test  -> Launches a window with a button that throws an Exception whenever it is clicked.
> ErrorLogging -> Aspect for the logging
> logging.lst -> Build configuration file
> 
> Thanks in advance,
> Hugo Magalhaães
> 
>   ------------------------------------------------------------------------------
>                       Name: LogTest.java
>    LogTest.java       Type: application/x-unknown-content-type-java_auto_file
>                   Encoding: base64
>                Description: LogTest.java
> 
>                   Name: Log.java
>    Log.java       Type: application/x-unknown-content-type-java_auto_file
>               Encoding: base64
>            Description: Log.java
> 
>                      Name: logging.lst
>    logging.lst       Type: unspecified type (application/octet-stream)
>                  Encoding: base64
>               Description: logging.lst
> 
>                            Name: ErrorLogging.java
>    ErrorLogging.java       Type: application/x-unknown-content-type-java_auto_file
>                        Encoding: base64
>                     Description: ErrorLogging.java


Back to the top