-
Notifications
You must be signed in to change notification settings - Fork 94
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
Application level error consumption and handling #186
Merged
Merged
Conversation
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
a3c3fcd
to
90e0b69
Compare
lrlna
reviewed
Jan 22, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you like, let's pair on this!
ad3c62c
to
5e81435
Compare
5e81435
to
d8f8dad
Compare
d8f8dad
to
80fb973
Compare
JakeDawkins
approved these changes
Jan 26, 2021
80fb973
to
ec917e8
Compare
lrlna
approved these changes
Jan 27, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good, @EverlastingBugstopper. Merge merge merge away!
c426244
to
3ecdae8
Compare
3ecdae8
to
6fbd736
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #146
This PR establishes patterns for application-level error handling in Rover by creating the
rover::error
module. This module exportsResult<T, RoverError>
, which is used in Rover to exit the application with the proper status code.RoverError
is a struct that wrapsanyhow::Error
and provides contextual information about the error in enumsOption<Code>
(error codes) andOption<Suggestion>
(possible solutions that helps the user troubleshoot). These are wrapped up into aMetadata
struct, which can be created from ananyhow::Error
.RoverError
also has aDisplay
implementation that is used in Rover to display the errors any way we like. I've taken a shot at a defaultDisplay
implementation here, but I'm very happy to work out the exact details on how it looks like with y'all.here's an example of an error with a solution:
once we add error codes, they will look something like this:
In
RoverError
's constructor,Code
andSolution
are created by taking advantage ofanyhow::Error::downcast
. This allows us to find the underlyingError
enum exported by various crates (likehouston::HoustonProblem
androver_client::RoverClientError
). Here, we can determine the error codes and solutions for various errors withmatch
statements on those library-provided error enums!I'm hoping this allows us to take a bit of an incremental approach to improving errors, as we see areas for improvement, we can extend our library error types, and adjust their solutions/error codes in
rover::error::metadata
.Let's merge this as is if it all looks good and then we can take care of improving individual errors and adding codes/suggestions incrementally.