wabbajack/Wabbajack.Networking.Http/HttpExtension.cs

24 lines
647 B
C#
Raw Normal View History

2021-09-27 12:42:46 +00:00
using System;
2020-05-20 03:25:41 +00:00
using System.Net.Http;
2020-01-07 13:50:11 +00:00
2021-09-27 12:42:46 +00:00
namespace Wabbajack.Networking.Http
2020-01-07 13:50:11 +00:00
{
public class HttpException : Exception
{
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
}
2021-09-27 12:42:46 +00:00
public string Reason { get; set; }
public int Code { get; set; }
2020-01-07 13:50:11 +00:00
}
2021-09-27 12:42:46 +00:00
}