using System.Net; namespace Hydra.Backend; public class HydraError(string message, Exception? inner = null) : Exception(message) { public Exception? Inner => inner; public class DatabaseError(string message, Exception? inner = null) : HydraError(message, inner); public class UnknownEntityError(Type entityType, Exception? inner = null) : DatabaseError($"Entity of type {entityType.Name} not found", inner); } public class ApiError(string message, HttpStatusCode? statusCode = null) : HydraError(message) { public readonly HttpStatusCode StatusCode = statusCode ?? HttpStatusCode.InternalServerError; public class Unauthorized(string message) : ApiError(message, statusCode: HttpStatusCode.Unauthorized); public class Forbidden(string message, IEnumerable? scopes = null) : ApiError(message, statusCode: HttpStatusCode.Forbidden) { public readonly string[] Scopes = scopes?.ToArray() ?? []; } public class AuthenticationError(string message) : ApiError(message, statusCode: HttpStatusCode.BadRequest); }