We currently define aitch::Error to be an alias for Box<Error>.
This was because:
- We wanted middleware to be as generic as possible, while requiring as few type parameters as possible. The hope that this would encourage users to create and share re-usable middleware, without having to specify an error type everywhere.
- It wasn't clear what downstream middleware/servers could do with the information in an error type. If a handler returns an error type, it's unlikely that the application could do much more than return a generic HTTP 500.
Since making this decision, we added the handler::static_files handlers, which attempt to catch io::Error and display a HTTP 404. These currently downcast the Box<Error>, which feels a little gross. Is there a better way?
Would aitch be more powerful if it somehow allowed users to specify a custom error type? What would that API look like?
Feedback very welcome!
We currently define
aitch::Errorto be an alias forBox<Error>.This was because:
Since making this decision, we added the
handler::static_fileshandlers, which attempt to catchio::Errorand display a HTTP 404. These currently downcast theBox<Error>, which feels a little gross. Is there a better way?Would aitch be more powerful if it somehow allowed users to specify a custom error type? What would that API look like?
Feedback very welcome!