fix: 에러 발생시 error로 return 되지 않도록 HTTPS status code 변경

-> success: false, HttpStatus.OK, code: 에러코드
     system 에러인 경우만 error로 return
dev
Jonguk. Lim 6 months ago
parent 27625123ab
commit ec4127f665

@ -47,7 +47,7 @@ public class CustomExceptionHandler {
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<ApiBaseResponse<?>> handleMethodArgumentNotValidException(MethodArgumentNotValidException ex) {
final String message = ex.getBindingResult().getAllErrors().get(0).getDefaultMessage();
return makeEntity(ResultCode.BAD_REQUEST.getStatusCode(), message, HttpStatus.BAD_REQUEST);
return makeEntity(ResultCode.BAD_REQUEST.getStatusCode(), message, HttpStatus.OK);
}
@ -58,7 +58,7 @@ public class CustomExceptionHandler {
*/
@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<ApiBaseResponse<?>> illegalArgumentException(IllegalArgumentException ex) {
return makeEntity(ResultCode.BAD_REQUEST.getStatusCode(), ex.getMessage(), HttpStatus.BAD_REQUEST);
return makeEntity(ResultCode.BAD_REQUEST.getStatusCode(), ex.getMessage(), HttpStatus.OK);
}
/**
@ -68,7 +68,7 @@ public class CustomExceptionHandler {
*/
@ExceptionHandler(NullPointerException.class)
public ResponseEntity<ApiBaseResponse<?>> handle(NullPointerException ex) {
return makeEntity(ResultCode.BAD_REQUEST.getStatusCode(), ex.getMessage(), HttpStatus.BAD_REQUEST);
return makeEntity(ResultCode.BAD_REQUEST.getStatusCode(), ex.getMessage(), HttpStatus.OK);
}
/**
@ -83,7 +83,7 @@ public class CustomExceptionHandler {
return makeEntity(ResultCode.UNAUTHORIZED.getStatusCode(), ex.getMessage(), HttpStatus.UNAUTHORIZED);
}
return makeEntity(ResultCode.BAD_REQUEST.getStatusCode(), ex.getMessage(), HttpStatus.BAD_REQUEST);
return makeEntity(ResultCode.BAD_REQUEST.getStatusCode(), ex.getMessage(), HttpStatus.OK);
}
/**
@ -100,7 +100,7 @@ public class CustomExceptionHandler {
return makeEntity(
ResultCode.INTERNAL_SERVER_ERROR.getStatusCode(),
"Does not support request method '" + req.getMethod() + "'",
HttpStatus.INTERNAL_SERVER_ERROR
HttpStatus.OK
);
}
@ -124,7 +124,7 @@ public class CustomExceptionHandler {
sb.append(fieldError.getDefaultMessage());
sb.append(", ");
}
return makeEntity(ResultCode.INVALID_DATA.getStatusCode(), sb.toString(), HttpStatus.valueOf(ResultCode.INVALID_DATA.getStatusCode()));
return makeEntity(ResultCode.INVALID_DATA.getStatusCode(), sb.toString(), HttpStatus.OK);
} else if (ex instanceof HttpMessageNotReadableException) {
resultCode = ResultCode.INVALID_DATA;
@ -139,7 +139,7 @@ public class CustomExceptionHandler {
resultCode = ResultCode.INTERNAL_SERVER_ERROR;
}
return makeEntity(resultCode.getStatusCode(), resultCode.getMessage(), HttpStatus.valueOf(resultCode.getStatusCode()));
return makeEntity(resultCode.getStatusCode(), resultCode.getMessage(), HttpStatus.OK);
}
/**
@ -152,7 +152,7 @@ public class CustomExceptionHandler {
if (Objects.equals(ex.getCode(), ResultCode.NO_CONTENT.getStatusCode())){
return new ResponseEntity<>(
ApiBaseResponse.builder()
.success(true)
.success(false)
.code(ex.getCode())
.message(ex.getMessage())
.build(),
@ -160,7 +160,7 @@ public class CustomExceptionHandler {
HttpStatus.OK
);
}
return makeEntity(ex.getCode(), ex.getMessage(), HttpStatus.BAD_REQUEST);
return makeEntity(ex.getCode(), ex.getMessage(), HttpStatus.OK);
}
private ResponseEntity<ApiBaseResponse<?>> makeEntity(final Integer code, final String message, final HttpStatus status) {

Loading…
Cancel
Save