I would be able to handle Exceptions within my `@C...
# spring
c
I would be able to handle Exceptions within my
@ControllerAdvice
Class, that have been thrown by Axon. For example, this dont work.
Copy code
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.
k
why do you think it is kotlin related?