From bab3f337c1908385766f7dce8d2193901fc6df62 Mon Sep 17 00:00:00 2001 From: forge-bot Date: Tue, 14 Jul 2026 06:25:58 +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 --- .../domain/exception/BusinessException.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/com/runtimematrix/domain/exception/BusinessException.java diff --git a/src/main/java/com/runtimematrix/domain/exception/BusinessException.java b/src/main/java/com/runtimematrix/domain/exception/BusinessException.java new file mode 100644 index 0000000..78fe91b --- /dev/null +++ b/src/main/java/com/runtimematrix/domain/exception/BusinessException.java @@ -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; } + } +}