From 9baed60278d766d1a39507c8d056d233301be7b4 Mon Sep 17 00:00:00 2001 From: Kerwin <37063904+zhuangchong@users.noreply.github.com> Date: Tue, 19 Jul 2022 17:29:29 +0800 Subject: [PATCH] add unknown exception message (#2204) --- .../org/apache/seatunnel/app/common/SeatunnelErrorEnum.java | 2 +- .../org/apache/seatunnel/app/util/GlobalExceptionHandler.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/common/SeatunnelErrorEnum.java b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/common/SeatunnelErrorEnum.java index 3f770b7256b..5e54ef5fac7 100644 --- a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/common/SeatunnelErrorEnum.java +++ b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/common/SeatunnelErrorEnum.java @@ -24,7 +24,7 @@ public enum SeatunnelErrorEnum { USER_ALREADY_EXISTS(10003, "user already exist", "The same username [%s] is exist."), NO_SUCH_USER(10002, "no such user", "No such user. Maybe deleted by others."), ILLEGAL_STATE(99998, "illegal state", "%s"), - UNKNOWN(99999, "unknown exception", "unknown exception") + UNKNOWN(99999, "unknown exception", "%s") ; private final int code; diff --git a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/util/GlobalExceptionHandler.java b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/util/GlobalExceptionHandler.java index 3b3678c30f3..511dbe5976e 100644 --- a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/util/GlobalExceptionHandler.java +++ b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/util/GlobalExceptionHandler.java @@ -52,11 +52,11 @@ private Result exceptionHandler(IllegalStateException e) { @ExceptionHandler(value = Exception.class) private Result exceptionHandler(Exception e) { logError(e); - return Result.failure(SeatunnelErrorEnum.UNKNOWN); + return Result.failure(SeatunnelErrorEnum.UNKNOWN, e.getMessage()); } private void logError(Throwable throwable) { - log.error("", throwable); + log.error(throwable.getMessage(), throwable); } }