28 lines
759 B
C#
28 lines
759 B
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
namespace Foxchat.Core.Models.Http;
|
|
|
|
public record ApiError
|
|
{
|
|
public required int Status { get; init; }
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public required ErrorCode Code { get; init; }
|
|
public required string Message { get; init; }
|
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
|
public ApiError? OriginalError { get; init; }
|
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
|
public string[]? Scopes { get; init; }
|
|
}
|
|
|
|
public enum ErrorCode
|
|
{
|
|
InternalServerError,
|
|
Unauthorized,
|
|
Forbidden,
|
|
BadRequest,
|
|
OutgoingFederationError,
|
|
AuthenticationError,
|
|
// TODO: more specific API error codes
|
|
GenericApiError,
|
|
}
|