using System.Net; namespace Foxchat.Core; public class FoxchatError(string message, Exception? inner = null) : Exception(message) { public Exception? Inner => inner; public class DatabaseError(string message, Exception? inner = null) : FoxchatError(message, inner); public class UnknownEntityError(Type entityType, Exception? inner = null) : FoxchatError($"Entity of type {entityType.Name} not found", inner); } public class ApiError(string message, HttpStatusCode? statusCode = null) : FoxchatError(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 BadRequest(string message) : ApiError(message, statusCode: HttpStatusCode.BadRequest); public class NotFound(string message) : ApiError(message, statusCode: HttpStatusCode.NotFound); public class IncomingFederationError(string message) : ApiError(message, statusCode: HttpStatusCode.BadRequest); public class OutgoingFederationError( string message, Models.Http.ApiError? innerError = null ) : ApiError(message, statusCode: HttpStatusCode.InternalServerError) { public Models.Http.ApiError? InnerError => innerError; } public class AuthenticationError(string message) : ApiError(message, statusCode: HttpStatusCode.BadRequest); }