using System;
namespace Unosquare.Swan.Exceptions {
///
/// Represents errors that occurs requesting a JSON file through HTTP.
///
///
#if !NETSTANDARD1_3
[Serializable]
#endif
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, Int32 httpErrorCode = 500, String errorContent = null)
: base(message) {
this.HttpErrorCode = httpErrorCode;
this.HttpErrorContent = errorContent;
}
///
/// Gets the HTTP error code.
///
///
/// The HTTP error code.
///
public Int32 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(this.HttpErrorContent) ? $"HTTP Response Status Code {this.HttpErrorCode} Error Message: {this.HttpErrorContent}" : base.ToString();
}
}