Class ExceptionLoggingAspect

java.lang.Object
io.github.tkasozi.aspect.ExceptionLoggingAspect

public class ExceptionLoggingAspect extends Object
This class implements an aspect to log exceptions that occur in classes annotated with Controller, Service, and RestController.
  • Constructor Details

    • ExceptionLoggingAspect

      public ExceptionLoggingAspect(@NonNull @NonNull EventLogRepository logRepository, Long ttl)
      Constructor.
      Parameters:
      logRepository - persistence layer for Event log.
      ttl - Time to live.
  • Method Details

    • excludeOwnMethods

      public void excludeOwnMethods()
      Pointcut to exclude methods in this library.
    • logExceptions

      public void logExceptions(org.aspectj.lang.JoinPoint joinPoint, Throwable exception)
      Handles exceptions that happen in Controller, Service, and RestController annotated classes.
      Parameters:
      joinPoint - The aspect that happened.
      exception - The exception that was thrown.