add methods for mapping error responses#2979
Open
robjtede wants to merge 2 commits into
Open
Conversation
Samielakkad
reviewed
Jul 17, 2026
Samielakkad
left a comment
There was a problem hiding this comment.
The idea of response mappers is interesting, but the public API as written has an extra generic type parameter that callers cannot infer:
pub fn add_mapper<F, B>(&mut self, mapper: F)
where
F: Fn(HttpResponse) -> HttpResponse + 'static,B is not used in the argument list, return type, or bounds, so a normal call like:
err.add_mapper(|res| res)will require the caller to specify a meaningless generic parameter or fail type inference. This should probably just be pub fn add_mapper<F>(...) unless B was intended to be part of the mapper signature.
It would also be good to add a small compile/pass test or unit test that actually calls add_mapper through the public API, so this kind of inference issue is caught.
robjtede
force-pushed
the
error-response-mapping
branch
from
July 17, 2026 11:03
eb10b74 to
473956a
Compare
robjtede
force-pushed
the
error-response-mapping
branch
from
July 17, 2026 12:00
473956a to
7b79694
Compare
robjtede
marked this pull request as ready for review
July 17, 2026 12:02
Member
Author
|
@JohnTitor basically an attempt to work around actix/actix-extras#680 in a nonbreaking way |
This file contains hidden or 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
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.
PR Type
Feature
PR Checklist
Overview
Give ability for users, middleware in particular, to alter the response generated from
Errors.