Skip to content

Commit

Permalink
Merge pull request #144 from WE-ARE-RACCOONS/develop
Browse files Browse the repository at this point in the history
RAC-304 deploy : ์šด์˜ ์„œ๋ฒ„ ์ ์šฉ
  • Loading branch information
ywj9811 authored Mar 2, 2024
2 parents 76efa0b + 7625c28 commit 3eae0a1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ private void jwtExceptionHandler(HttpStatus status, HttpServletResponse response
response.setStatus(status.value());
response.setContentType(CONTENT_TYPE);
response.setCharacterEncoding(CHARACTER_ENCODING);
log.error("errorCode {}, errorMessage {}", ex.getErrorCode(), ex.getMessage());
log.error("errorCode {}, errorMessage {}", ex.getCode(), ex.getMessage());
try {
logService.save(new LogRequest(env, JwtFilter.class.getSimpleName(), ex.getMessage()));
String json = new ObjectMapper().writeValueAsString(ResponseDto.create(ex.getErrorCode(), ex.getMessage()));
String json = new ObjectMapper().writeValueAsString(ResponseDto.create(ex.getCode(), ex.getMessage()));
response.getWriter().write(json);
} catch (Exception e) {
log.error(e.getMessage());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/postgraduate/global/dto/ErrorResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
@Getter
@RequiredArgsConstructor
public class ErrorResponse {
private String errorCode;
private String code;
private String message;

public ErrorResponse(String errorCode, String message) {
this.errorCode = errorCode;
public ErrorResponse(String code, String message) {
this.code = code;
this.message = message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

@Getter
public abstract class ApplicationException extends RuntimeException{
private final String errorCode;
private final String code;

protected ApplicationException(String message, String errorCode) {
protected ApplicationException(String message, String code) {
super(message);
this.errorCode = errorCode;
this.code = code;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public class GlobalExceptionHandler {

@ExceptionHandler(ApplicationException.class)
public ResponseDto<ErrorResponse> handleApplicationException(ApplicationException ex) {
return ResponseDto.create(ex.getErrorCode(), ex.getMessage());
return ResponseDto.create(ex.getCode(), ex.getMessage());
}

@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseDto<ErrorResponse> handleArgumentValidException(MethodArgumentNotValidException ex) throws IOException {
public ResponseDto<ErrorResponse> handleArgumentValidException(MethodArgumentNotValidException ex) {
logService.save(new LogRequest(env, "@Valid", ex.getBindingResult().getAllErrors().get(0).getDefaultMessage()));
log.error(LOG_FORMAT, "@Valid Error", "MethodArgumentNotValidException");
return ResponseDto.create(ErrorCode.VALID_BLANK.getCode(), ex.getBindingResult().getAllErrors().get(0).getDefaultMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private Object getObject(ProceedingJoinPoint joinPoint) throws Throwable {
return result;
}catch (ApplicationException e) {
if (traceStatus != null) {
log.error("ErrorCode {} errorMessage {}",e.getErrorCode(), e.getMessage());
log.error("ErrorCode {} errorMessage {}",e.getCode(), e.getMessage());
log.error("{}", e.getStackTrace());
logService.save(new LogRequest(env, traceStatus.threadId(), traceStatus.methodName(), e.getMessage()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Integer end(TraceStatus traceStatus) { // ๊ฑธ๋ฆฐ ์‹œ๊ฐ„ ๋กœ๊ทธ ์ฒ˜๋ฆฌ ๋ฐ

public void exception(ApplicationException e, TraceStatus traceStatus) {
log.error("class : {}, trace : {}", traceStatus.methodName(), e.getStackTrace());
log.error(LOG_FORMAT, traceStatus.threadId(), e.getErrorCode(), e.getMessage());
log.error(LOG_FORMAT, traceStatus.threadId(), e.getCode(), e.getMessage());
removeMdcContext();
}

Expand Down

0 comments on commit 3eae0a1

Please sign in to comment.