Uwaa/Pleroma/Models/PleromaException.cs

32 lines
816 B
C#
Raw Normal View History

2024-12-13 13:25:20 +01:00
namespace Uwaa.Pleroma;
2024-11-22 09:55:08 +01:00
2024-12-26 00:08:58 +01:00
public abstract class PleromaException : Exception
{
public override string ToString() => Message;
}
public class PleromaSimpleException : PleromaException
2024-11-22 09:55:08 +01:00
{
[JsonPropertyName("error")]
public string Text { get; set; } = null!;
public override string Message => Text;
}
2024-12-18 17:04:26 +01:00
2024-12-26 00:08:58 +01:00
public class PleromaAggregateException : PleromaException
2024-12-18 17:04:26 +01:00
{
[JsonPropertyName("errors")]
public PleromaInnerException[] Text { get; set; } = null!;
public override string Message => string.Join("\n", (object?[])Text);
2024-12-26 00:08:58 +01:00
public override Exception GetBaseException() => Text == null ? this : Text[0];
2024-12-18 17:04:26 +01:00
}
2024-12-26 00:08:58 +01:00
public class PleromaInnerException : PleromaException
2024-12-18 17:04:26 +01:00
{
[JsonPropertyName("detail")]
public string Text { get; set; } = null!;
public override string Message => Text;
}