refactor(基础模块): 优化http异常错误码

This commit is contained in:
zhouhao
2024-09-09 16:26:06 +08:00
parent 17b4cbd608
commit 04e2fe8edf

View File

@@ -61,16 +61,16 @@ public class CommonErrorControllerAdvice {
.map(msg -> {
HttpStatus status = HttpStatus.resolve(msg.getStatus());
return ResponseEntity
.status(status == null ? HttpStatus.INTERNAL_SERVER_ERROR : status)
.status(status == null ? HttpStatus.BAD_REQUEST : status)
.body(msg);
});
}
@ExceptionHandler
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public Mono<ResponseMessage<Object>> handleException(UnsupportedOperationException e) {
return LocaleUtils
.resolveThrowable(e, (err, msg) -> (ResponseMessage.error(500, CodeConstants.Error.unsupported, msg)))
.resolveThrowable(e, (err, msg) -> (ResponseMessage.error(400, CodeConstants.Error.unsupported, msg)))
.doOnEach(ReactiveLogger.onNext(r -> log.warn(e.getLocalizedMessage(), e)));
}