- 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
37 lines
1.1 KiB
C#
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);
|
|
}
|