Christopher Hübner
02/12/2024, 11:58 AM@ControllerAdvice
Class, that have been thrown by Axon. For example, this dont work.
typealias SpringExceptionHandler = org.springframework.web.bind.annotation.ExceptionHandler
typealias AxonExceptionHandler = org.axonframework.messaging.interceptors.ExceptionHandler
@ControllerAdvice
class ExceptionHandler : ResponseEntityExceptionHandler() {
@SpringExceptionHandler
fun handleEventExceptions(
exception: NoHandlerForCommandException, request: WebRequest
): ResponseEntity<*> {
return handleExceptionInternal(
exception, exception.message, HttpHeaders(), HttpStatus.UNPROCESSABLE_ENTITY, request
)!!
}
@SpringExceptionHandler
fun handleCommandBusException(
exception: CommandBusException, request: WebRequest
): ResponseEntity<Any> {
return handleExceptionInternal(
exception, exception.message, HttpHeaders(), HttpStatus.UNPROCESSABLE_ENTITY, request
)!!
}
}
Exceptions are thrown, but I cant handle them within my controller with try catch, nor by a ExceptionHandler.kqr
02/12/2024, 12:39 PM