-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: throw BoxApiError in C# fetch, add additional data to ResponseI…
…nfo (box/box-codegen#439) (#23)
- Loading branch information
1 parent
480a710
commit 6dce6d7
Showing
12 changed files
with
166 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{ "engineHash": "905c6a0", "specHash": "b2f7568", "version": "0.1.0" } | ||
{ "engineHash": "df5b5de", "specHash": "b2f7568", "version": "0.1.0" } |
This file was deleted.
Oops, something went wrong.
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
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,17 @@ | ||
using System; | ||
|
||
namespace Errors | ||
{ | ||
public class BoxApiException : BoxSdkException | ||
{ | ||
public RequestInfo RequestInfo { get; set; } | ||
|
||
public ResponseInfo ResponseInfo { get; set; } | ||
|
||
public BoxApiException(string message, DateTimeOffset timeStamp, RequestInfo requestInfo, ResponseInfo responseInfo) : base(message, timeStamp, "BoxApiException") | ||
{ | ||
RequestInfo = requestInfo; | ||
ResponseInfo = responseInfo; | ||
} | ||
} | ||
} |
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,19 @@ | ||
using System; | ||
|
||
namespace Errors | ||
{ | ||
public class BoxSdkException : Exception | ||
{ | ||
public System.DateTimeOffset? Timestamp { get; set; } = default; | ||
|
||
public string? Error { get; set; } = default; | ||
|
||
public string Name { get; set; } | ||
|
||
public BoxSdkException(string message, DateTimeOffset? timeStamp = null, string name = "BoxSdkException") : base(message) | ||
{ | ||
Name = name; | ||
Timestamp = timeStamp ?? DateTimeOffset.UtcNow; | ||
} | ||
} | ||
} |
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,26 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Errors | ||
{ | ||
public class RequestInfo | ||
{ | ||
public string Method { get; set; } | ||
|
||
public string Url { get; set; } | ||
|
||
public IReadOnlyDictionary<string, string> QueryParams { get; set; } | ||
|
||
public IReadOnlyDictionary<string, string> Headers { get; set; } | ||
|
||
public string? Body { get; set; } = default; | ||
|
||
public RequestInfo(string method, string? url, IReadOnlyDictionary<string, string>? queryParams, IReadOnlyDictionary<string, string> headers) | ||
{ | ||
Method = method; | ||
Url = url ?? ""; | ||
QueryParams = queryParams ?? new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()); | ||
Headers = headers; | ||
} | ||
} | ||
} |
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,56 @@ | ||
using Serialization.Json; | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Errors | ||
{ | ||
public class ResponseInfo | ||
{ | ||
public int StatusCode { get; set; } | ||
|
||
public IReadOnlyDictionary<string, string> Headers { get; set; } | ||
|
||
public SerializedData? Body { get; set; } = default; | ||
|
||
public string? RawBody { get; set; } = default; | ||
|
||
public string? Code { get; set; } = default; | ||
|
||
public Dictionary<string, object>? ContextInfo { get; set; } = default; | ||
|
||
public string? RequestId { get; set; } = default; | ||
|
||
public string? HelpUrl { get; set; } = default; | ||
|
||
public ResponseInfo(int statusCode, IReadOnlyDictionary<string, string> headers, SerializedData body, string rawBody, | ||
string? code, Dictionary<string, object>? contextInfo, string? requestId, string? helpUrl) | ||
{ | ||
StatusCode = statusCode; | ||
Headers = headers; | ||
Body = body; | ||
RawBody = rawBody; | ||
Code = code; | ||
ContextInfo = contextInfo ?? new Dictionary<string, object>(); | ||
RequestId = requestId; | ||
HelpUrl = helpUrl; | ||
} | ||
} | ||
|
||
internal class BoxApiExceptionDetails | ||
{ | ||
[JsonPropertyName("code")] | ||
public string? Code { get; set; } | ||
|
||
[JsonPropertyName("context_info")] | ||
public Dictionary<string, object>? ContextInfo { get; set; } | ||
|
||
[JsonPropertyName("request_id")] | ||
public string? RequestId { get; set; } | ||
|
||
[JsonPropertyName("help_url")] | ||
public string? HelpUrl { get; set; } | ||
|
||
public BoxApiExceptionDetails() { } | ||
} | ||
|
||
} |
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