Skip to content

Commit

Permalink
fix: error handling with status code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeongh00 committed Nov 8, 2024
1 parent 2641377 commit 5ae9a3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.web.bind.annotation.ResponseStatus;

@Getter
@ResponseStatus(HttpStatus.BAD_REQUEST)
public class AlbumCustomException extends RuntimeException {

private final BaseErrorCode errorCode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pocket.core.exception.common;

import com.pocket.core.exception.album.AlbumCustomException;
import com.pocket.core.exception.jwt.SecurityCustomException;
import com.pocket.core.exception.photobooth.PhotoBoothCustomException;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -28,4 +29,12 @@ public ResponseEntity<ApplicationResponse<String>> handleSecurityException(Secur
return new ResponseEntity<>(response, ex.getErrorCode().getHttpStatus());
}

@ExceptionHandler(AlbumCustomException.class)
public ResponseEntity<ApplicationResponse<String>> handleAlbumCustomException(AlbumCustomException ex) {
ApplicationResponse<String> response = new ApplicationResponse<>(
new ApplicationResult(Integer.parseInt(ex.getErrorCode().getCode()), ex.getErrorCode().getMessage()),
null
);
return new ResponseEntity<>(response, ex.getErrorCode().getHttpStatus());
}
}

0 comments on commit 5ae9a3f

Please sign in to comment.