Skip to content

Commit

Permalink
Error handling: custom variant for server errors
Browse files Browse the repository at this point in the history
  • Loading branch information
piegamesde committed Oct 10, 2021
1 parent 523be54 commit 424c0f9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ pub enum WormholeCoreError {
/// the server sent some bullshit message order
#[error("Protocol error: {}", _0)]
Protocol(Box<str>),
/// The server sent us an error message
#[error("Received error message from server: {}", _0)]
Server(Box<str>),
#[error(
"Key confirmation failed. If you didn't mistype the code, \
this is a sign of an attacker guessing passwords. Please try \
Expand Down Expand Up @@ -397,11 +400,9 @@ pub async fn run(
orig: _,
}) => {
// TODO maybe hanlde orig field for better messages
// Also, make this a proper error type, maybe ServerError or RemoteError
actions.push_back(Event::ShutDown(Err(WormholeCoreError::protocol(format!(
"Received error message from server: {}",
message
)))));
actions.push_back(Event::ShutDown(Err(WormholeCoreError::Server(
message.into(),
))));
},
FromIO(InboundMessage::Pong { .. }) | FromIO(InboundMessage::Ack { .. }) => (), /* we ignore this, it's only for the timing log */
FromIO(InboundMessage::Unknown) => {
Expand Down

0 comments on commit 424c0f9

Please sign in to comment.