Skip to content

Commit 424c0f9

Browse files
committed
Error handling: custom variant for server errors
1 parent 523be54 commit 424c0f9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/core.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ pub enum WormholeCoreError {
4141
/// the server sent some bullshit message order
4242
#[error("Protocol error: {}", _0)]
4343
Protocol(Box<str>),
44+
/// The server sent us an error message
45+
#[error("Received error message from server: {}", _0)]
46+
Server(Box<str>),
4447
#[error(
4548
"Key confirmation failed. If you didn't mistype the code, \
4649
this is a sign of an attacker guessing passwords. Please try \
@@ -397,11 +400,9 @@ pub async fn run(
397400
orig: _,
398401
}) => {
399402
// TODO maybe hanlde orig field for better messages
400-
// Also, make this a proper error type, maybe ServerError or RemoteError
401-
actions.push_back(Event::ShutDown(Err(WormholeCoreError::protocol(format!(
402-
"Received error message from server: {}",
403-
message
404-
)))));
403+
actions.push_back(Event::ShutDown(Err(WormholeCoreError::Server(
404+
message.into(),
405+
))));
405406
},
406407
FromIO(InboundMessage::Pong { .. }) | FromIO(InboundMessage::Ack { .. }) => (), /* we ignore this, it's only for the timing log */
407408
FromIO(InboundMessage::Unknown) => {

0 commit comments

Comments
 (0)