Skip to content
New issue

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

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

Already on GitHub? # to your account

Show error source list when printing handler error #1358

Merged
merged 1 commit into from
Apr 6, 2023
Merged

Conversation

rylev
Copy link
Collaborator

@rylev rylev commented Apr 5, 2023

This changes the Rust SDK to print out the causes of any error returned from the HTTP handler. This can make debugging much easier.

For example, take the following error handling code in an HTTP handler:

let query: Query = serde_qs::from_str(query_string).context("failed to parse query parameters")?;

Previously this would print out:

Handler returned an error: failed to parse query parameters

Now this prints out:

Handler returned an error: failed to parse query parameters
  caused by: missing field `email`

Now it is immediately clear that the cause is the missing email parameter.

This can be further improved with some creative use of emoji and terminal colors, but that should be left to a future improvement.

Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Copy link
Contributor

@itowlson itowlson left a comment

Choose a reason for hiding this comment

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

approved on the strict condition that you do not "improve it with the creative use of emoji"

@itowlson itowlson requested a review from fibonacci1729 April 5, 2023 21:12
@rylev rylev merged commit fd6069c into main Apr 6, 2023
@rylev rylev deleted the error-chain branch April 6, 2023 07:40
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants