foxcord/Foxcord/Rest/RestException.cs

28 lines
740 B
C#
Raw Normal View History

2024-07-02 01:14:46 +02:00
using System.Net;
using System.Text.Json.Nodes;
using Foxcord.Serialization;
namespace Foxcord.Rest;
public class RestException : Exception
{
public HttpStatusCode StatusCode { get; private init; }
public int Code { get; private init; }
public new string Message { get; private init; }
public string? Errors { get; private init; }
internal RestException(HttpStatusCode statusCode, ErrorResponse response)
{
StatusCode = statusCode;
Code = response.Code;
Message = response.Message;
Errors = response.Errors?.ToJsonString();
}
public enum ErrorCode
{
GeneralError = 0
}
internal record ErrorResponse(int Code, string Message, JsonObject? Errors);
}