ai-dev-template / csharp /src /Core /Exceptions /AppException.cs
Jordandevlog's picture
Upload csharp/src/Core/Exceptions/AppException.cs
fd72e32 verified
Raw
History Blame Contribute Delete
950 Bytes
namespace AiDevProject.Core.Exceptions;
/// <summary>
/// Base application exception.
/// </summary>
public class AppException : Exception
{
public int StatusCode { get; }
public bool IsOperational { get; }
public AppException(string message, int statusCode = 500, bool isOperational = true)
: base(message)
{
StatusCode = statusCode;
IsOperational = isOperational;
}
}
/// <summary>
/// Validation error.
/// </summary>
public class ValidationError : AppException
{
public ValidationError(string message) : base(message, 400) { }
}
/// <summary>
/// Resource not found.
/// </summary>
public class NotFoundError : AppException
{
public NotFoundError(string resource) : base($"{resource} not found", 404) { }
}
/// <summary>
/// Authentication failed.
/// </summary>
public class AuthenticationError : AppException
{
public AuthenticationError() : base("Authentication failed", 401) { }
}