map the response of the ws.send call into a LuaError

This commit is contained in:
AsynchronousMatrix 2023-07-19 12:48:54 +01:00
parent 4ed7cafc77
commit e5a844ecec

View file

@ -154,8 +154,7 @@ where
{
let mut ws = socket.write_stream.lock().await;
let _ = ws
.send(WsMessage::Close(Some(WsCloseFrame {
ws.send(WsMessage::Close(Some(WsCloseFrame {
code: match code {
Some(code) if (1000..=4999).contains(&code) => WsCloseCode::from(code),
Some(code) => {
@ -167,7 +166,8 @@ where
},
reason: "".into(),
})))
.await;
.await
.map_err(LuaError::external)?;
let res = ws.close();
res.await.map_err(LuaError::external)