SPMS_API/SPMS.Domain/Exceptions/SpmsException.cs
SEAN f04eb44fff improvement: 서비스 스코프 정책 고정 (#199)
- ErrorCodes.ServiceScopeRequired("133") 추가
- SpmsException.Forbidden 팩토리 추가
- ServiceCodeMiddleware 3-카테고리 라우팅 (SKIP/REQUIRED/OPTIONAL_FOR_ADMIN)
- Swagger 필터 stats/device-list X-Service-Code optional 표시
- StatsController/DeviceController GetOptionalServiceId() 적용
- IStatsService/IDeviceService/레포지토리 시그니처 long? serviceId 변경
- StatsService/DeviceService null serviceId 전체 서비스 모드 처리

Closes #199
2026-02-24 17:11:30 +09:00

37 lines
1.1 KiB
C#

using SPMS.Domain.Common;
namespace SPMS.Domain.Exceptions;
public class SpmsException : Exception
{
public string ErrorCode { get; }
public int HttpStatusCode { get; }
public SpmsException(string errorCode, string message, int httpStatusCode = 400)
: base(message)
{
ErrorCode = errorCode;
HttpStatusCode = httpStatusCode;
}
// === 팩토리 메서드 ===
public static SpmsException BadRequest(string message)
=> new(ErrorCodes.BadRequest, message, 400);
public static SpmsException Unauthorized(string message)
=> new(ErrorCodes.Unauthorized, message, 401);
public static SpmsException NotFound(string message)
=> new(ErrorCodes.NotFound, message, 404);
public static SpmsException Conflict(string message)
=> new(ErrorCodes.Conflict, message, 409);
public static SpmsException Forbidden(string message)
=> new(ErrorCodes.Forbidden, message, 403);
public static SpmsException LimitExceeded(string message)
=> new(ErrorCodes.LimitExceeded, message, 429);
}