TA 역할 Spring 경계 smoke #6
1 changed files with 72 additions and 0 deletions
|
|
@ -0,0 +1,72 @@
|
|||
package com.klaroworks.runtime.rolematrix.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
/** 도메인 예외 기본 클래스 */
|
||||
public abstract class DomainException extends RuntimeException {
|
||||
private final String errorCode;
|
||||
private final HttpStatus defaultStatus;
|
||||
|
||||
protected DomainException(String message, String errorCode, HttpStatus defaultStatus) {
|
||||
super(message);
|
||||
this.errorCode = errorCode;
|
||||
this.defaultStatus = defaultStatus;
|
||||
}
|
||||
|
||||
protected DomainException(String message, String errorCode, HttpStatus defaultStatus, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.errorCode = errorCode;
|
||||
this.defaultStatus = defaultStatus;
|
||||
}
|
||||
|
||||
public String getErrorCode() { return errorCode; }
|
||||
public HttpStatus getDefaultStatus() { return defaultStatus; }
|
||||
}
|
||||
|
||||
/** 역할 매트릭스를 찾을 수 없을 때 */
|
||||
class RoleMatrixNotFoundException extends DomainException {
|
||||
private final Long roleMatrixId;
|
||||
public RoleMatrixNotFoundException(Long roleMatrixId) {
|
||||
super(String.format("역할 매트릭스를 찾을 수 없습니다. ID: %d", roleMatrixId), "NOT_FOUND_ROLE_MATRIX", HttpStatus.NOT_FOUND);
|
||||
this.roleMatrixId = roleMatrixId;
|
||||
}
|
||||
public Long getRoleMatrixId() { return roleMatrixId; }
|
||||
}
|
||||
|
||||
/** 중복된 역할 매트릭스 */
|
||||
class DuplicateRoleMatrixException extends DomainException {
|
||||
private final String matrixName;
|
||||
public DuplicateRoleMatrixException(String matrixName) {
|
||||
super(String.format("이미 존재하는 역할 매트릭스입니다. 이름: %s", matrixName), "CONFLICT_DUPLICATE_MATRIX", HttpStatus.CONFLICT);
|
||||
this.matrixName = matrixName;
|
||||
}
|
||||
public String getMatrixName() { return matrixName; }
|
||||
}
|
||||
|
||||
/** 입력 검증 실패 */
|
||||
class ValidationException extends RuntimeException {
|
||||
private final String errorCode;
|
||||
public ValidationException(String message) { super(message); this.errorCode = "VAL_INVALID_INPUT"; }
|
||||
public ValidationException(String message, String errorCode) { super(message); this.errorCode = errorCode; }
|
||||
public String getErrorCode() { return errorCode; }
|
||||
}
|
||||
|
||||
/** 인프라 예외 기본 클래스 */
|
||||
abstract class InfrastructureException extends RuntimeException {
|
||||
private final String errorCode;
|
||||
private final HttpStatus defaultStatus;
|
||||
protected InfrastructureException(String message, String errorCode, HttpStatus defaultStatus) {
|
||||
super(message); this.errorCode = errorCode; this.defaultStatus = defaultStatus;
|
||||
}
|
||||
protected InfrastructureException(String message, String errorCode, HttpStatus defaultStatus, Throwable cause) {
|
||||
super(message, cause); this.errorCode = errorCode; this.defaultStatus = defaultStatus;
|
||||
}
|
||||
public String getErrorCode() { return errorCode; }
|
||||
public HttpStatus getDefaultStatus() { return defaultStatus; }
|
||||
}
|
||||
|
||||
/** 데이터베이스 접근 예외 */
|
||||
class DataAccessException extends InfrastructureException {
|
||||
public DataAccessException(String message) { super(message, "SYS_DATABASE_ERROR", HttpStatus.INTERNAL_SERVER_ERROR); }
|
||||
public DataAccessException(String message, Throwable cause) { super(message, "SYS_DATABASE_ERROR", HttpStatus.INTERNAL_SERVER_ERROR, cause); }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue