Replace expect usage with Result
This commit is contained in:
parent
9394a1ae52
commit
b3228ea6b5
11 changed files with 135 additions and 95 deletions
emgauwa-core/src/handlers/v1/ws/controllers
|
@ -116,14 +116,17 @@ impl StreamHandler<Result<Message, ProtocolError>> for ControllerWs {
|
|||
let action_res = self.handle_action(&mut pool_conn, ctx, action);
|
||||
if let Err(e) = action_res {
|
||||
log::error!("Error handling action: {:?}", e);
|
||||
ctx.text(serde_json::to_string(&e).expect("Failed to serialize error"));
|
||||
ctx.text(
|
||||
serde_json::to_string(&e)
|
||||
.unwrap_or(format!("Error in handling action: {:?}", e)),
|
||||
);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Error deserializing action: {:?}", e);
|
||||
ctx.text(
|
||||
serde_json::to_string(&EmgauwaError::Serialization(e))
|
||||
.expect("Failed to serialize error"),
|
||||
.unwrap_or(String::from("Error in deserializing action")),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue