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

#[autoprops_component] panics instead of making a proper error #3

Closed
kirillsemyonkin opened this issue May 23, 2023 · 0 comments · Fixed by #10
Closed

#[autoprops_component] panics instead of making a proper error #3

kirillsemyonkin opened this issue May 23, 2023 · 0 comments · Fixed by #10

Comments

@kirillsemyonkin
Copy link
Collaborator

As of writing, yew-autoprops uses panic!() macro to display errors to the user. This, however, is not intended and causes jarring error:

#[autoprops_component]
pub fn Example(i: u32) -> Html {
    html! {}
}

#[function_component]
pub fn App() -> Html {
    html! {
        <Example i={ 0 } />
    }
}

Error:

custom attribute panicked
message: Invalid argument: i : u32 (must be a reference)

Possible Solutions

  • Generate compile_error!() instead of panic!()ing, this should cause a proper simple error to be displayed to the user of the library.
  • In future, as Rust features stabilize, consider using Diagnostic API.
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 a pull request may close this issue.

1 participant