RaspberryIO_26/Swan/Net/JsonRequestException.cs

45 lines
1.4 KiB
C#
Raw Normal View History

2019-12-08 21:23:54 +01:00
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 {
2019-12-04 18:57:18 +01:00
/// <summary>
2019-12-08 21:23:54 +01:00
/// Initializes a new instance of the <see cref="JsonRequestException"/> class.
2019-12-04 18:57:18 +01:00
/// </summary>
2019-12-08 21:23:54 +01:00
/// <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();
}
2019-12-04 18:57:18 +01:00
}