From 8cc53a6c4939e2c98affaf1c389fcd7ebab1a56a Mon Sep 17 00:00:00 2001 From: forge-bot Date: Tue, 14 Jul 2026 06:31:52 +0000 Subject: [PATCH] =?UTF-8?q?TA=20=EC=97=AD=ED=95=A0=20Spring=20=EA=B2=BD?= =?UTF-8?q?=EA=B3=84=20smoke=20(role-ta-live-1522-001)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rolematrix/exception/Exceptions.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/main/java/com/klaroworks/runtime/rolematrix/exception/Exceptions.java diff --git a/src/main/java/com/klaroworks/runtime/rolematrix/exception/Exceptions.java b/src/main/java/com/klaroworks/runtime/rolematrix/exception/Exceptions.java new file mode 100644 index 0000000..90d1401 --- /dev/null +++ b/src/main/java/com/klaroworks/runtime/rolematrix/exception/Exceptions.java @@ -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); } +}