Return Json error with status code
IgnisDa opened this issue · 2 comments
IgnisDa commented
Thanks for this awesome project! The examples are a bit lacking on how to work with returning errors and status code.
For example I have a handler:
#[axum::debug_handler]
pub async fn create_user(
State(pool): State<PgPool>,
Json(user): Json<CreateUserInput>,
) -> Result<(StatusCode, Json<CreateUserOutput>), (StatusCode, Json<CreateUserOutputError>)> {
}
This raises errors. I could be doing something wrong and would be glad if someone could guide me.
Wicpar commented
Can you provide the error? It's likely that your struct does not derive JsonSchema
IgnisDa commented
I got this working in a different way, thanks for responding.