Skip to content

Commit

Permalink
refactor(networking): use TerminateNode event instead of panic!
Browse files Browse the repository at this point in the history
  • Loading branch information
mickvandijke committed Aug 2, 2024
1 parent 25a2b90 commit 7e2be6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions sn_networking/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ pub enum NetworkEvent {
#[derive(Debug, Clone)]
pub enum TerminateNodeReason {
HardDiskWriteError,
UpnpGatewayNotFound,
}

// Manually implement Debug as `#[debug(with = "unverified_record_fmt")]` not working as expected.
Expand Down
6 changes: 5 additions & 1 deletion sn_networking/src/event/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

use crate::event::TerminateNodeReason;
use crate::{
cmd::LocalSwarmCmd,
event::NodeEvent,
Expand Down Expand Up @@ -81,7 +82,10 @@ impl SwarmDriver {
event_string = "upnp_event";
info!(?upnp_event, "UPnP event");
if let libp2p::upnp::Event::GatewayNotFound = upnp_event {
panic!("UPnP is not enabled/supported on your gateway. Please rerun without the `--upnp` flag");
warn!("UPnP is not enabled/supported on the gateway. Please rerun without the `--upnp` flag");
self.send_event(NetworkEvent::TerminateNode {
reason: TerminateNodeReason::UpnpGatewayNotFound,
});
}
}

Expand Down

0 comments on commit 7e2be6c

Please sign in to comment.