38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
|
||
namespace Vanguard.Api
|
||
{
|
||
/// <summary>Ошибка HTTP-API с сохранением кода и сообщения сервера.</summary>
|
||
public sealed class ApiException : Exception
|
||
{
|
||
public long StatusCode { get; }
|
||
public string Code { get; }
|
||
public IReadOnlyList<ApiViolation> Violations { get; }
|
||
|
||
public ApiException(
|
||
long statusCode,
|
||
string code,
|
||
string message,
|
||
IReadOnlyList<ApiViolation> violations = null)
|
||
: base(message)
|
||
{
|
||
StatusCode = statusCode;
|
||
Code = code ?? string.Empty;
|
||
Violations = violations ?? Array.Empty<ApiViolation>();
|
||
}
|
||
}
|
||
|
||
public sealed class ApiViolation
|
||
{
|
||
public string Code { get; }
|
||
public string Message { get; }
|
||
|
||
public ApiViolation(string code, string message)
|
||
{
|
||
Code = code ?? string.Empty;
|
||
Message = message ?? string.Empty;
|
||
}
|
||
}
|
||
}
|