Skip to content

Commit

Permalink
update client bad request ErrorInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
hank-cp committed Dec 22, 2023
1 parent 0f9b581 commit 1e47dc5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public ErrorInfo clone() {
public static final ErrorInfo PARSE_METHOD_NOT_FOUND = ErrorInfo.of(1017, "error.PARSE_METHOD_NOT_FOUND", ErrorLevel.FATAL);
public static final ErrorInfo INVALID_CONFIGURATION = ErrorInfo.of(1019, "error.INVALID_CONFIGURATION", ErrorLevel.FATAL);
public static final ErrorInfo BAD_IMPLEMENTATION = ErrorInfo.of(1020, "error.BAD_IMPLEMENTATION", ErrorLevel.FATAL);
public static final ErrorInfo BAD_REQUEST = ErrorInfo.of(1021, "error.BAD_REQUEST");

public static final ErrorInfo AUTHENTICATION_REQUIRED = ErrorInfo.of(1100, "error.AUTHENTICATION_REQUIRED");
public static final ErrorInfo BAD_CERTIFICATION = ErrorInfo.of(1101, "error.BAD_CERTIFICATION");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object bo
HttpHeaders headers,
HttpStatusCode status,
WebRequest request) {
applicationContext.publishEvent(new ErrorOccurredEvent(ex, request));
Object standerBody = Optional.ofNullable(body)
.orElse(exceptionFormatter.convert(ex));
return super.handleExceptionInternal(ex, standerBody, headers, status, request);
Object respBody;
if (status.value() == HttpStatus.BAD_REQUEST.value()
|| status.value() == HttpStatus.NOT_FOUND.value()
|| status.value() == HttpStatus.METHOD_NOT_ALLOWED.value()) {
respBody = ErrorInfo.BAD_REQUEST.msgArgs(status.value());
} else {
applicationContext.publishEvent(new ErrorOccurredEvent(ex, request));
respBody = Optional.ofNullable(body)
.orElse(exceptionFormatter.convert(ex));
}
return super.handleExceptionInternal(ex, respBody, headers, status, request);
}

@ExceptionHandler(ConfException.class)
Expand Down
1 change: 1 addition & 0 deletions skr-common/src/main/resources/skr-error.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ error.MISSING_ARGUMENT=\u53C2\u6570{0}\u672A\u8BBE\u7F6E
error.PARSE_METHOD_NOT_FOUND=\u679A\u4E3E\u7C7B\u578B{0}\u672A\u6B63\u786E\u914D\u7F6E
error.INVALID_CONFIGURATION=\u9519\u8BEF\u914D\u7F6E: {0}
error.BAD_IMPLEMENTATION=\u903B\u8F91\u5F02\u5E38: {0}
error.BAD_REQUEST=\u975E\u6CD5\u8BF7\u6C42({0})

error.AUTHENTICATION_REQUIRED=\u672A\u63D0\u4F9B\u8BA4\u8BC1\u4FE1\u606F
error.BAD_CERTIFICATION=\u65E0\u6548\u7684\u767B\u5F55\u51ED\u8BC1: {0}
Expand Down

0 comments on commit 1e47dc5

Please sign in to comment.