TA 역할 Spring 경계 smoke #3

Open
forge-bot wants to merge 9 commits from forge/role-ta-live-1522-001-attempt-1-run-6e84b72613b1 into main
Showing only changes of commit bab3f337c1 - Show all commits

View file

@ -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; }
}
}