VanguardReMaster/client/Assets/Vanguard/Runtime/Api/ApiException.cs

38 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}
}