-
Notifications
You must be signed in to change notification settings - Fork 81
feat: error handle generation on validation fail #563
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
feat: error handle generation on validation fail #563
Conversation
|
Thanks for picking this up! |
use pavex_macros::error_handler;
#[error_handler(id = "CUSTOM")]
pub fn invalid_handler(_a: &str, _b: u64) -> pavex::Response {
todo!()
}
fn test_handle_exists() {
let _handle = CUSTOM;
}
fn main() {}^ The above should not cause an error in |
|
I'm not able to understand the better approach.. as custom id is already honored like this in the error_handler.rs -> Err(e) => { and in emit function and the test also does not cause an error in "fn test_handle_exists" ig a better approach would be to re-emit striped functions? as now it only emits the error and handler should i implement this approach? @LukeMathWalker |
| if let Ok(mut foreign_fn) = syn::parse2::<syn::ForeignItemFn>(input.clone()) { | ||
| crate::utils::PxStripper.visit_foreign_item_fn_mut(&mut foreign_fn); | ||
| return quote! { #error_tokens #foreign_fn }.into(); | ||
| } |
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.
No need to handle foreign functions, it's a usecase that we won't officially support for a while, probably ever.
| fn visit_foreign_item_fn_mut(&mut self, node: &mut ForeignItemFn) { | ||
| strip_pavex_attrs(&mut node.attrs); | ||
| visit_mut::visit_foreign_item_fn_mut(self, node); | ||
| } |
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.
Same as above, let's remove it.
|
You're right, I was thinking of a slightly different scenario—parsing the entire metadata fails, but we can successfully parse a subset of it out (i.e. the id). |
|
/ok-to-test sha=3f7f2b9 |
|
Thanks! |
I learnt alot, while reading the codebase... thanks to you ❤️ |
implements follow-up #538
1.entrypoint expect() would cause panic, handled err better
2.PxStripper for Impl and Trait aswell
3.add ast nodes functions to re-emit with input
4.stripped almost at all entrypoints
5.also generated handle constants when validation fails... is it graceful?
add a fail test as suggested in issue.