-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from ShipEngine/jpill/include-http-response-wi…
…th-error feat: initialize SDK with httpClient, add HttpResponseMessage to Exception
- Loading branch information
Showing
13 changed files
with
578 additions
and
116 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,48 @@ | ||
#pragma warning disable 1591 | ||
|
||
using System; | ||
using System.Net.Http; | ||
|
||
namespace ShipEngineSDK | ||
{ | ||
/// <summary> | ||
/// Error object returned from failed method calls | ||
/// </summary> | ||
public class ShipEngineException : Exception | ||
public class ShipEngineException( | ||
string message, | ||
ErrorSource errorSource = ErrorSource.Shipengine, | ||
ErrorType errorType = ErrorType.System, | ||
ErrorCode errorCode = ErrorCode.Unspecified, | ||
string? requestID = null, | ||
HttpResponseMessage? responseMessage = null) | ||
: Exception(message) | ||
{ | ||
/// <summary> | ||
/// A UUID that uniquely identifies the request id. | ||
/// This can be given to the support team to help debug non-trivial issues that may occur | ||
/// </summary> | ||
|
||
public string? RequestId { get; } | ||
public string? RequestId { get; } = requestID; | ||
|
||
/// <summary> | ||
/// The source of the error, as indicated by the name this informs us if the API call failed | ||
/// because of the carrier, the order source, or the ShipEngine API itself. | ||
/// </summary> | ||
public ErrorSource ErrorSource { get; set; } | ||
public ErrorSource ErrorSource { get; set; } = errorSource; | ||
|
||
/// <summary> | ||
/// The type of error | ||
/// </summary> | ||
public ErrorType ErrorType { get; set; } | ||
public ErrorType ErrorType { get; set; } = errorType; | ||
|
||
/// <summary> | ||
/// The error code specified for the failed API Call | ||
/// </summary> | ||
public ErrorCode ErrorCode { get; set; } | ||
public ErrorCode ErrorCode { get; set; } = errorCode; | ||
|
||
|
||
public ShipEngineException( | ||
string message, | ||
ErrorSource errorSource = ErrorSource.Shipengine, | ||
ErrorType errorType = ErrorType.System, | ||
ErrorCode errorCode = ErrorCode.Unspecified, | ||
string requestID = null) : base(message) | ||
{ | ||
ErrorSource = errorSource; | ||
ErrorType = errorType; | ||
ErrorCode = errorCode; | ||
RequestId = requestID; | ||
} | ||
/// <summary> | ||
/// The http response message returned from the failed API call | ||
/// </summary> | ||
public HttpResponseMessage? ResponseMessage { get; set; } = responseMessage; | ||
} | ||
} |
Oops, something went wrong.