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

Remove explicit status from return code, instead relying on TypedError's status() method. #1

Open
wants to merge 38 commits into
base: typed-catchers
Choose a base branch
from

Conversation

the10thWiz
Copy link
Owner

I think this is the direction I want to go. It simplifies the API a bit, going from (Status, Option<dyn TypedError>) to Box<dyn TypedError>. This also eases the transition for existing code, since this is going from Status in 0.5 to Box<dyn TypedError> with this PR. Status implements TypedError, so a basic upgrade, with no additional work, is to simply wrap the Status 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 a NotFound 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 as Responders - and the source() mechanism provides a convenient way to support catching the inner type.

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant