fix: server function custom errors set status codes (#4782)
* fix: handling status codes from errors * add demo * clippy + check * fix clippy again
This commit is contained in:
1 parent
fc069f0faf
commit
8f6e7dc1f2
9 files changed
+356
-44
No files matched your search
@@ -200,9 +200,9 @@ pub fn current_status() -> StreamingStatus {
|
||||
pub fn status_code_from_error(error: &CapturedError) -> StatusCode {
|
||||
if let Some(err) = error.downcast_ref::<ServerFnError>() {
|
||||
match err {
|
||||
ServerFnError::ServerError {
|
||||
code: Some(code), ..
|
||||
} => return StatusCode::from_u16(*code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR),
|
||||
ServerFnError::ServerError { code, .. } => {
|
||||
return StatusCode::from_u16(*code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
_ => return StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user