You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When returning an Err(http_types::Error) inside a handler that returns a tide::Result, the message for the error is not displayed in the browser if the status is StatusCode::InternalServerError. I can work around this by returning Ok(Response) with StatusCode::InternalServerError. It seems like it is an anti-pattern to return Ok(Response) when an error occurred on the server. Just looking for some clarification the correct approach.
Thanks!
The text was updated successfully, but these errors were encountered:
The solution for this in tide >= 0.12 is to add a middleware that catches responses with an attached error and builds a string body with it, something like:
app.middleware(After(|mutres:Response| async{ifletSome(err) = res.take_error(){
res.set_body(err.to_string())// or json, or html, etc, whatever is appropriate for your app}Ok(res)}));
tide/src/server.rs
Line 416 in 293610b
When returning an Err(http_types::Error) inside a handler that returns a tide::Result, the message for the error is not displayed in the browser if the status is StatusCode::InternalServerError. I can work around this by returning Ok(Response) with StatusCode::InternalServerError. It seems like it is an anti-pattern to return Ok(Response) when an error occurred on the server. Just looking for some clarification the correct approach.
Thanks!
The text was updated successfully, but these errors were encountered: