Skip to content

Commit

Permalink
Merge pull request #3231 from KouShenhai/dev
Browse files Browse the repository at this point in the history
feat: 优化代码【异常捕获】
  • Loading branch information
KouShenhai authored Dec 30, 2024
2 parents 311902a + fe43c48 commit c4ce18f
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static void write(File file, InputStream in, long size, long chunkSize) t
inChannel.transferTo(finalPosition, finalEndSize, outChannel);
}
catch (IOException e) {
throw new SystemException("S_UnKnow_Error", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage(), e);
}
return true;
});
Expand All @@ -137,7 +137,7 @@ public static void write(File file, InputStream in, long size, long chunkSize) t
catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("错误信息:{}", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage(), e);
}
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ private static void replaceFromEnd(String sourcePath, char oldChar, char newChar
}
}
catch (IOException e) {
throw new SystemException("S_UnKnow_Error", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static String getContent(String template, Map<String, Object> params) {
}
catch (Exception e) {
log.error("错误信息:{}", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public final class RSAUtil {
}
catch (IOException e) {
log.error("读取私钥或密钥失败,错误信息:{}", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ public BizException(String code, String msg) {
super(code, msg);
}

public BizException(String code, String msg, Throwable throwable) {
super(code, msg, throwable);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ protected GlobalException(String code, String msg) {
this.msg = msg;
}

protected GlobalException(String code, String msg, Throwable throwable) {
super(msg, throwable);
this.code = code;
this.msg = msg;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public ParamException(String code, String msg) {
super(code, msg);
}

public ParamException(String code, String msg, Throwable throwable) {
super(code, msg, throwable);
}

public final static class OAuth2 {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public SystemException(String code, String msg) {
super(code, msg);
}

public SystemException(String code, String msg, Throwable throwable) {
super(code, msg, throwable);
}

public final static class Gateway {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public <T, M> void batch(List<T> dataList, int batchNum, int timeout, Class<M> c
catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("错误信息:{}", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage(), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void executeInTransaction(DatabaseOperation operation) {
catch (Exception e) {
r.setRollbackOnly();
log.error("操作失败,错误信息:{}", e.getMessage());
throw new SystemException("S_DS_OperationError", e.getMessage());
throw new SystemException("S_DS_OperationError", e.getMessage(), e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Authentication authenticate(Authentication authentication) {
}
catch (IOException e) {
log.error("认证授权失败,错误信息:{}", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage());
throw new SystemException("S_UnKnow_Error", e.getMessage(), e);
}
}

Expand Down

0 comments on commit c4ce18f

Please sign in to comment.