Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Creating BoxAuthenticationFailedException no longer throws an exception #790

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Box.V2/Exceptions/BoxAuthenticationFailedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ protected internal BoxSessionInvalidatedException(string message, BoxError error

protected internal static new BoxSessionInvalidatedException GetResponseException<T>(string message, IBoxResponse<T> response) where T : class
{
var ex = BoxAPIException.GetResponseException(message, response);

return (BoxSessionInvalidatedException)ex;
var error = GetResponseError(response);
return new BoxSessionInvalidatedException(GetErrorMessage(message, response, error), response.Error, response.StatusCode, response.Headers);
}
}
}
11 changes: 8 additions & 3 deletions Box.V2/Exceptions/BoxException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ protected internal BoxAPIException(string message, BoxError error, HttpStatusCod
/// <param name="message">The message from the SDK about what happened</param>
/// <param name="response">The HTTP response that generated the exception</param>
protected internal static BoxAPIException GetResponseException<T>(string message, IBoxResponse<T> response) where T : class
{
var error = GetResponseError(response);
return new BoxAPIException(GetErrorMessage(message, response, error), response.Error, response.StatusCode, response.Headers);
}

protected internal static BoxError GetResponseError<T>(IBoxResponse<T> response) where T : class
{
BoxError error = null;
if (!string.IsNullOrWhiteSpace(response.ContentString))
Expand All @@ -76,12 +82,11 @@ protected internal BoxAPIException(string message, BoxError error, HttpStatusCod
Debug.WriteLine(string.Format("Unable to parse error message: {0} ({1})", response.ContentString, e.Message));
}
}
var ex = new BoxAPIException(GetErrorMessage(message, response, error), response.Error, response.StatusCode, response.Headers);

return ex;
return error;
}

private static string GetErrorMessage<T>(string message, IBoxResponse<T> response, BoxError error = null) where T : class
protected internal static string GetErrorMessage<T>(string message, IBoxResponse<T> response, BoxError error = null) where T : class
{
var requestID = error?.RequestId;
string traceID = null;
Expand Down