1

I have custom SubscriberNotFoundException class which extends Exception class. I want to pointcut its some methods using aspects for catching exceptions and logging to file.

Here is my code:

    try {
          --------
        } 
        catch (SubscriberNotFoundException e) 
        { 
            return ResponseEntity.status(HttpStatus.BAD_REQUEST)
            .body(new Response(e.getCode(),  e.getMessage(), null));
        }

my custom class:

@ToString
@Getter   
public class SubscriberNotFoundException extends Exception {

    ------
}

The problem is that pointcut cannot handle this methods of SubscriberNotFoundException class.

I have tryed all case of pointcut syntax, for example

@Pointcut("within(com.xyz.someapp.web..*)")
@Pointcut("execution(* com.xyz.someapp.service.*.*(..))")

and others, so i think that's not the problem.

  • Welcome to SO. Please learn [how to ask a question on SO](https://stackoverflow.com/help/how-to-ask) and provide a [minimal, complete, and verifiable example](https://stackoverflow.com/help/mcve), not pseudo code snippets out of context. Thank you. Please also explain if your target classes (the ones to be intercepted) are Spring components or non-Spring classes. That would determine if you can use Spring AOP or need native AspectJ. – kriegaex Jan 16 '23 at 15:26

0 Answers0