namespace Swan.Net
{
using System;
///
/// Represents errors that occurs requesting a JSON file through HTTP.
///
///
[Serializable]
public class JsonRequestException
: Exception
{
///
/// Initializes a new instance of the class.
///
/// The message.
/// The HTTP error code.
/// Content of the error.
public JsonRequestException(string message, int httpErrorCode = 500, string errorContent = null)
: base(message)
{
HttpErrorCode = httpErrorCode;
HttpErrorContent = errorContent;
}
///
/// Gets the HTTP error code.
///
///
/// The HTTP error code.
///
public int HttpErrorCode { get; }
///
/// Gets the content of the HTTP error.
///
///
/// The content of the HTTP error.
///
public string HttpErrorContent { get; }
///
public override string ToString() => string.IsNullOrEmpty(HttpErrorContent)
? $"HTTP Response Status Code {HttpErrorCode} Error Message: {HttpErrorContent}"
: base.ToString();
}
}