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