25 lines
1.2 KiB
C#
25 lines
1.2 KiB
C#
namespace NTP.Application.Common;
|
|
|
|
public sealed class NotFoundException(string entity, object key)
|
|
: Exception($"{entity} '{key}' was not found.");
|
|
|
|
/// <summary>Raised when an UPDATE/DELETE affects 0 rows because ROW_VERSION changed.</summary>
|
|
public sealed class ConcurrencyException(string entity, object key)
|
|
: Exception($"{entity} '{key}' was modified by another user. Reload and retry.");
|
|
|
|
/// <summary>
|
|
/// A business-rule violation ported from legacy code (HTTP 422). <c>message</c> is the user-facing text
|
|
/// (keep the legacy Arabic wording); <c>code</c> is a stable machine-readable code returned to the client
|
|
/// as the ProblemDetails extension "code".
|
|
/// </summary>
|
|
public class BusinessException(string code, string message) : Exception(message)
|
|
{
|
|
public string Code { get; } = code;
|
|
}
|
|
|
|
/// <summary>Credentials / account state rejected (HTTP 401). Same shape as <see cref="BusinessException"/>.</summary>
|
|
public sealed class AuthenticationFailedException(string code, string message) : BusinessException(code, message);
|
|
|
|
/// <summary>Authenticated but the role/rules do not allow the action (HTTP 403).</summary>
|
|
public sealed class ForbiddenException(string code, string message) : BusinessException(code, message);
|