TA 역할 Spring 경계 smoke (role-ta-live-1522-001)
This commit is contained in:
parent
e414a834ad
commit
bab3f337c1
1 changed files with 42 additions and 0 deletions
|
|
@ -0,0 +1,42 @@
|
|||
package com.runtimematrix.domain.exception;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* 비즈니스 로직 수행 중 발생하는 예외의 기본 클래스.
|
||||
* 모든 도메인 예외는 이 클래스를 상속한다.
|
||||
*/
|
||||
public abstract class BusinessException extends RuntimeException {
|
||||
|
||||
private final String errorCode;
|
||||
private final String resourceId;
|
||||
|
||||
protected BusinessException(String errorCode, String message, String resourceId) {
|
||||
super(message);
|
||||
this.errorCode = errorCode;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public String getErrorCode() { return errorCode; }
|
||||
public String getResourceId() { return resourceId; }
|
||||
public abstract int getHttpStatus();
|
||||
public String getType() { return "https://api.runtimematrix.com/errors/" + errorCode; }
|
||||
|
||||
/** 역할 미존재 예외 */
|
||||
public static class RoleNotFoundException extends BusinessException {
|
||||
private static final String CODE = "role-not-found";
|
||||
public RoleNotFoundException(String roleId) {
|
||||
super(CODE, MessageFormat.format("ID가 ''{0}''인 역할을 찾을 수 없습니다.", roleId), roleId);
|
||||
}
|
||||
@Override public int getHttpStatus() { return 404; }
|
||||
}
|
||||
|
||||
/** 역할 중복 예외 */
|
||||
public static class RoleAlreadyExistsException extends BusinessException {
|
||||
private static final String CODE = "role-already-exists";
|
||||
public RoleAlreadyExistsException(String roleName) {
|
||||
super(CODE, MessageFormat.format("이름이 ''{0}''인 역할이 이미 존재합니다.", roleName), roleName);
|
||||
}
|
||||
@Override public int getHttpStatus() { return 409; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue