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

Improve error handling #147

Merged
merged 3 commits into from
Aug 29, 2023
Merged
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
4 changes: 2 additions & 2 deletions src/ConductorSharp.Client/Service/ConductorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ private void CheckResponse(RestResponse response)

_logger.LogInformation("Received {@Response} with status code {@StatusCode}", response.Content, (int)response.StatusCode);

error = JsonConvert.DeserializeObject<ConductorErrorResponse>(response.Content);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of a transport error, this would crash with:

System.ArgumentNullException: Value cannot be null. (Parameter 'value')

error = response.Content != null ? JsonConvert.DeserializeObject<ConductorErrorResponse>(response.Content) : null;

if (error == null || string.IsNullOrEmpty(error.Message))
throw new Exception("Unable to deserialize error");
throw new Exception(response.ErrorMessage ?? "Unable to deserialize error");

_logger.LogError("{@conductorError}", error);

Expand Down
Loading