45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using System;
|
|
|
|
namespace Swan.Net {
|
|
/// <summary>
|
|
/// Represents errors that occurs requesting a JSON file through HTTP.
|
|
/// </summary>
|
|
/// <seealso cref="System.Exception" />
|
|
[Serializable]
|
|
public class JsonRequestException : Exception {
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="JsonRequestException"/> class.
|
|
/// </summary>
|
|
/// <param name="message">The message.</param>
|
|
/// <param name="httpErrorCode">The HTTP error code.</param>
|
|
/// <param name="errorContent">Content of the error.</param>
|
|
public JsonRequestException(String message, Int32 httpErrorCode = 500, String errorContent = null) : base(message) {
|
|
this.HttpErrorCode = httpErrorCode;
|
|
this.HttpErrorContent = errorContent;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the HTTP error code.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The HTTP error code.
|
|
/// </value>
|
|
public Int32 HttpErrorCode {
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the content of the HTTP error.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The content of the HTTP error.
|
|
/// </value>
|
|
public String HttpErrorContent {
|
|
get;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override String ToString() => String.IsNullOrEmpty(this.HttpErrorContent) ? $"HTTP Response Status Code {this.HttpErrorCode} Error Message: {this.HttpErrorContent}" : base.ToString();
|
|
}
|
|
}
|