Skip to content

Commit

Permalink
feat: AsyncExceptionHandler 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
suw0n committed May 8, 2024
1 parent 914f11e commit a1186ae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package b1nd.dodamapi.common.async;

import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

Expand All @@ -11,7 +13,7 @@

@Configuration
@EnableAsync
class AsyncConfig {
class AsyncConfig implements AsyncConfigurer {

@Bean
@Primary
Expand All @@ -26,4 +28,9 @@ public Executor asyncExecutor() {
return executor;
}

@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return new AsyncExceptionHandler();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package b1nd.dodamapi.common.async;

import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;

import java.lang.reflect.Method;

@Slf4j
public class AsyncExceptionHandler implements AsyncUncaughtExceptionHandler {

@Override
public void handleUncaughtException(Throwable ex, Method method, Object... params) {
log.error("message : " + ex.getMessage());
log.error("method : " + method);
for(Object param : params) {
log.error("param : " + param);
}
}

}

0 comments on commit a1186ae

Please sign in to comment.