forked from rwf2/Rocket
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Remove explicit status from return code, instead relying on TypedError
's status()
method.
#1
Open
the10thWiz
wants to merge
38
commits into
typed-catchers
Choose a base branch
from
typed-catchers-no-status
base: typed-catchers
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
- Catchers now carry `TypeId` and type name for collision detection - Transient updated to 0.3, with new derive macro - Added `Transient` or `Static` implementations for error types - CI should now pass
See catch attribute docs for the new syntax.
- Add Error trait - Use Option<Box<dyn Error>> - Update Responder to return a result - Update all core implementations
- Update Responder derive to match new trait - Update lifecycle to deal with error types correctly - Update catcher rank to ignore type - now handled by lifecycle
Still has several major missing features, but is back to passing CI.
- The previous `on_request` was unsafe, now uses a separate `filter_request` method to ensure `error` only contains immutable borrows of `Request`. - Added full safety comments and arguements to `erased`. - Added extra logic to upgrade, to prevent upgrading if an error has been thrown.
- Also makes some changes to the catch attribute to fix issues identified during testing
- Add `FromParamError` and `FromSegementsError` - Updated codegen to generate these types. - Fixed some codegen issues along the way.
- Updates tests to use new `#[catch]` syntax - Updates error-handling to take full advantage of new features - Fixes priority issue with catchers
- Avoid allocating in a bunch of cases - Fix responder to work in as many cases as possible - Fix a couple minor warnings
the10thWiz
force-pushed
the
typed-catchers
branch
from
November 22, 2024 05:31
c263a6c
to
0b72867
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.
I think this is the direction I want to go. It simplifies the API a bit, going from
(Status, Option<dyn TypedError>)
toBox<dyn TypedError>
. This also eases the transition for existing code, since this is going fromStatus
in 0.5 toBox<dyn TypedError>
with this PR.Status
implementsTypedError
, so a basic upgrade, with no additional work, is to simply wrap theStatus
in a Box.The major reason I want to move this route, is that in most cases, the appropriate status code can be derived from the error itself. There may be a few cases where it can't, such as
std::io::Error
, which may have different meanings depending on the operation that was attempted. (E.g., normally aNotFound
error would map to a 404 status, but if the server always expects the file to exist, it might actually map to a 500 error). These cases can pretty trivially be handled by defining useful wrappers, in much the same way asResponder
s - and thesource()
mechanism provides a convenient way to support catching the inner type.