| 123456789101112131415161718192021222324252627282930313233343536 |
- package com.seec.bok.service.exception;
- import lombok.Getter;
- import lombok.ToString;
- import org.springframework.http.HttpStatus;
- @Getter
- @ToString
- public class ServiceException extends RuntimeException {
- private int error;
- public ServiceException() {
- this(HttpStatus.INTERNAL_SERVER_ERROR.value(), HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
- }
- public ServiceException(int error) {
- this(error, message(error));
- }
- public ServiceException(String message) {
- this(HttpStatus.INTERNAL_SERVER_ERROR.value(), message);
- }
- public ServiceException(int error, String message) {
- super(message);
- this.error = error;
- }
- private static String message(int error) {
- try {
- return HttpStatus.valueOf(error).getReasonPhrase();
- } catch (IllegalArgumentException e) {
- return HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase();
- }
- }
- }
|