mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
map the response of the ws.send
call into a LuaError
This commit is contained in:
parent
4ed7cafc77
commit
e5a844ecec
1 changed files with 14 additions and 14 deletions
|
@ -154,20 +154,20 @@ where
|
|||
{
|
||||
let mut ws = socket.write_stream.lock().await;
|
||||
|
||||
let _ = ws
|
||||
.send(WsMessage::Close(Some(WsCloseFrame {
|
||||
code: match code {
|
||||
Some(code) if (1000..=4999).contains(&code) => WsCloseCode::from(code),
|
||||
Some(code) => {
|
||||
return Err(LuaError::RuntimeError(format!(
|
||||
"Close code must be between 1000 and 4999, got {code}"
|
||||
)))
|
||||
}
|
||||
None => WsCloseCode::Normal,
|
||||
},
|
||||
reason: "".into(),
|
||||
})))
|
||||
.await;
|
||||
ws.send(WsMessage::Close(Some(WsCloseFrame {
|
||||
code: match code {
|
||||
Some(code) if (1000..=4999).contains(&code) => WsCloseCode::from(code),
|
||||
Some(code) => {
|
||||
return Err(LuaError::RuntimeError(format!(
|
||||
"Close code must be between 1000 and 4999, got {code}"
|
||||
)))
|
||||
}
|
||||
None => WsCloseCode::Normal,
|
||||
},
|
||||
reason: "".into(),
|
||||
})))
|
||||
.await
|
||||
.map_err(LuaError::external)?;
|
||||
|
||||
let res = ws.close();
|
||||
res.await.map_err(LuaError::external)
|
||||
|
|
Loading…
Add table
Reference in a new issue