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

Adding the debug macro to the templates to have better errors. #547

Merged
merged 3 commits into from
May 3, 2024

Conversation

Muxoid
Copy link
Contributor

@Muxoid Muxoid commented Apr 18, 2024

I'm new to Axum and Loco frameworks and encountered an error when trying to use a handler to return HTML instead of JSON. The issue stemmed from not adding Json as the final argument in the handler function, which the improved error message helped identify as you can see below.

I thought this would help with new users and DX, there might be a better way, let me know what you think. Maybe simply adding it to the docs might be sufficient.

Doc

image

@jondot
Copy link
Contributor

jondot commented Apr 19, 2024

This is great. Looks like there's no performance hit when compiling with --release which is fantastic.
I'm wondering how we can include this by default in all handlers, without letting the user manually type it above every single handler, is there such a way?

@Muxoid
Copy link
Contributor Author

Muxoid commented Apr 20, 2024

I do not think it would be possible without changing the Axum code to make this default behavior. As it is the impl IntoResponse code that causes the complex error. The macro was created to solve the issue.

Axum into_response.rs

@Muxoid
Copy link
Contributor Author

Muxoid commented Apr 30, 2024

I have added it to the code generator templates as well.

@kaplanelad
Copy link
Contributor

kaplanelad commented May 3, 2024

Thanks @Muxoid

@kaplanelad kaplanelad merged commit bc5df88 into loco-rs:master May 3, 2024
20 checks passed
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.

3 participants