Skip to content

Commit

Permalink
fix: Creating BoxAuthenticationFailedException no longer throws an ex…
Browse files Browse the repository at this point in the history
…ception (#790)
  • Loading branch information
arjankowski committed Jan 4, 2022
1 parent 4f1f70a commit 55a706e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions Box.V2/Exceptions/BoxAuthenticationFailedException.cs
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
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

0 comments on commit 55a706e

Please sign in to comment.