2020-01-07 13:50:11 +00:00
|
|
|
|
using System;
|
2020-05-20 03:25:41 +00:00
|
|
|
|
using System.Net.Http;
|
2020-05-23 21:03:25 +00:00
|
|
|
|
using Wabbajack.Common.Serialization.Json;
|
2020-01-07 13:50:11 +00:00
|
|
|
|
|
2020-05-21 22:12:51 +00:00
|
|
|
|
namespace Wabbajack.Common.Exceptions
|
2020-01-07 13:50:11 +00:00
|
|
|
|
{
|
2020-05-23 21:03:25 +00:00
|
|
|
|
[JsonName("HttpException")]
|
2020-01-07 13:50:11 +00:00
|
|
|
|
public class HttpException : Exception
|
|
|
|
|
{
|
|
|
|
|
public string Reason { get; set; }
|
|
|
|
|
public int Code { get; set; }
|
|
|
|
|
|
|
|
|
|
public HttpException(int code, string reason) : base($"Http Error {code} - {reason}")
|
|
|
|
|
{
|
|
|
|
|
Code = code;
|
|
|
|
|
Reason = reason;
|
|
|
|
|
}
|
2020-05-20 03:25:41 +00:00
|
|
|
|
|
|
|
|
|
public HttpException(HttpResponseMessage response) : base(
|
|
|
|
|
$"Http Error {response.StatusCode} - {response.ReasonPhrase}")
|
|
|
|
|
{
|
|
|
|
|
Code = (int)response.StatusCode;
|
2020-12-31 23:39:18 +00:00
|
|
|
|
Reason = response.ReasonPhrase ?? "Unknown";
|
2020-05-20 03:25:41 +00:00
|
|
|
|
}
|
2020-01-07 13:50:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|