Package io.github.tkasozi.aspect
Class ExceptionLoggingAspect
java.lang.Object
io.github.tkasozi.aspect.ExceptionLoggingAspect
This class implements an aspect to log exceptions
that occur in classes annotated with Controller, Service,
and RestController.
-
Constructor Summary
ConstructorsConstructorDescriptionExceptionLoggingAspect
(@NonNull EventLogRepository logRepository, Long ttl) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Pointcut to exclude methods in this library.void
logExceptions
(org.aspectj.lang.JoinPoint joinPoint, Throwable exception) Handles exceptions that happen in Controller, Service, and RestController annotated classes.
-
Constructor Details
-
ExceptionLoggingAspect
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
Handles exceptions that happen in Controller, Service, and RestController annotated classes.- Parameters:
joinPoint
- The aspect that happened.exception
- The exception that was thrown.
-