Skip to content

Commit

Permalink
improved error msg for ActorSpawnHandle::await_unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMurray committed May 13, 2024
1 parent 3d2d100 commit c25c495
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/actor/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ impl ActorSpawnHandle {
/// spawn_handle.await_ready().unwrap()

Check failure on line 314 in src/actor/actor.rs

View workflow job for this annotation

GitHub Actions / Test

cannot find value `spawn_handle` in this scope
/// ```
pub fn await_unwrap(&self) -> ActorAddress {
let res = self.await_ready();
// If there is an error, panic with a descriptive message of what went wrong
if let Err(e) = res {
panic!("Failed while waiting for actor spawn: {}", e);
}
self.await_ready().unwrap()
}
}
10 changes: 10 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Display;

/// Error type for all errors originating from library actions
#[derive(Debug)]
pub enum BusanError {
Expand All @@ -6,3 +8,11 @@ pub enum BusanError {
/// a user focused explanation of the specific error cause.
UnassignableActor(String),
}

impl Display for BusanError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
BusanError::UnassignableActor(s) => write!(f, "Actor is unassignable: {}", s),
}
}
}

0 comments on commit c25c495

Please sign in to comment.