-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
91 extend exception for keeping internal info from http response (#94)
- Loading branch information
1 parent
47da8c3
commit efc1072
Showing
8 changed files
with
72 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Net; | ||
using System.Net.Http; | ||
|
||
namespace ReportPortal.Client | ||
{ | ||
/// <summary> | ||
/// Occurs when server cannot process a request. | ||
/// </summary> | ||
public class ServiceException : Exception | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of <see cref="ServiceException"/> class. | ||
/// </summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
/// <param name="httpStatusCode">Response HTTP status code.</param> | ||
/// <param name="requestUri">Request Uri.</param> | ||
/// <param name="httpMethod">HTTP method.</param> | ||
/// <param name="responseBody">Response body.</param> | ||
public ServiceException(string message, HttpStatusCode httpStatusCode, Uri requestUri, HttpMethod httpMethod, string responseBody) | ||
{ | ||
HttpStatusCode = httpStatusCode; | ||
RequestUri = requestUri; | ||
HttpMethod = httpMethod; | ||
ResponseBody = responseBody; | ||
|
||
_message = $"{message}\n {httpStatusCode} ({(int)httpStatusCode}) {httpMethod} {requestUri}\n {responseBody}"; | ||
} | ||
|
||
private readonly string _message; | ||
|
||
/// <summary> | ||
/// Gets HTTP status code. | ||
/// </summary> | ||
public HttpStatusCode HttpStatusCode { get; } | ||
|
||
/// <summary> | ||
/// Gets request uri. | ||
/// </summary> | ||
public Uri RequestUri { get; } | ||
|
||
/// <summary> | ||
/// Gets HTTP method. | ||
/// </summary> | ||
public HttpMethod HttpMethod { get; } | ||
|
||
/// <summary> | ||
/// Gets response body. | ||
/// </summary> | ||
public string ResponseBody { get; } | ||
|
||
/// <inheritdoc/> | ||
public override string Message => _message; | ||
} | ||
} |
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
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
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
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
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