Search in sources :

Example 1 with AsyncUncaughtExceptionHandler

use of org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler in project CzechIdMng by bcvsolutions.

the class AsyncConfig method getAsyncUncaughtExceptionHandler.

@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    // simple error logging
    return new AsyncUncaughtExceptionHandler() {

        @Override
        public void handleUncaughtException(Throwable throwable, Method method, Object... obj) {
            if (throwable instanceof ResultCodeException) {
                ResultCodeException ex = (ResultCodeException) throwable;
                LOG.error("[" + ex.getId() + "] ", ex);
            } else {
                ErrorModel errorModel = new DefaultErrorModel(CoreResultCode.INTERNAL_SERVER_ERROR, throwable.getMessage());
                LOG.error("[" + errorModel.getId() + "] ", throwable);
            }
        }
    };
}
Also used : AsyncUncaughtExceptionHandler(org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultErrorModel(eu.bcvsolutions.idm.core.api.exception.DefaultErrorModel) ErrorModel(eu.bcvsolutions.idm.core.api.exception.ErrorModel) Method(java.lang.reflect.Method) DefaultErrorModel(eu.bcvsolutions.idm.core.api.exception.DefaultErrorModel)

Aggregations

DefaultErrorModel (eu.bcvsolutions.idm.core.api.exception.DefaultErrorModel)1 ErrorModel (eu.bcvsolutions.idm.core.api.exception.ErrorModel)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 Method (java.lang.reflect.Method)1 AsyncUncaughtExceptionHandler (org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler)1