Created
October 24, 2014 18:56
-
-
Save ctigeek/b9223f760e7472f5f736 to your computer and use it in GitHub Desktop.
An exception that will encapsulate the details of a web call without embedding the specific response object. Using with RestClient.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//boy am I looking forward to read-only classes in c# ver6. | |
public class WebResponseException : Exception | |
{ | |
public readonly HttpStatusCode StatusCode; | |
public readonly string RequestUrl; | |
public readonly string RequestMethod; | |
public readonly Dictionary<string, string> RequestHeaders; | |
public readonly Dictionary<string, string> ResponseHeaders; | |
public readonly string ResponseBody; | |
public WebResponseException(string message, HttpStatusCode statusCode, string requestUrl, | |
string requestMethod, | |
Exception innerException = null, | |
Dictionary<string, string> requestHeaders = null, | |
Dictionary<string, string> responseHeaders = null, | |
string responseBody = null) | |
: base(message, innerException) | |
{ | |
this.StatusCode = statusCode; | |
this.RequestMethod = requestMethod; | |
this.RequestUrl = requestUrl; | |
this.RequestHeaders = requestHeaders ?? new Dictionary<string, string>(); | |
this.ResponseHeaders = responseHeaders ?? new Dictionary<string, string>(); | |
this.ResponseBody = responseBody; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment