Skip to content

Conversation

@hnorkowski
Copy link
Contributor

@hnorkowski hnorkowski commented Nov 13, 2025

Closes #257

Adds a const boolean TELL_PANIC_ON_ERR to trait Actor which is set to true by default and when

  • is true: does not change the current behavior
  • is false: ignores when the answer to a tell(..) contains Err(..)

Because the bool is const it should not introduce any runtime overhead.

Writing Tests

I was unsure where it would be appropriate to place a test for that behavior. If you want me to add one please tell me where it should be placed and I will happily add one 😃

@tqwewe
Copy link
Owner

tqwewe commented Nov 14, 2025

@hnorkowski I've made a commit adding the new PanicReason enum, which supports a bunch of reasons for a panic to have occurred.

I think this is a great addition, so thank you for opening the issue/pr! Does this enum solve your issue?

kameo/src/error.rs

Lines 634 to 663 in 2887710

/// Describes the cause of an actor panic or fatal error.
///
/// In kameo, several error conditions are treated as panics, triggering the
/// [`on_panic`](crate::actor::Actor::on_panic) lifecycle hook and potentially
/// stopping the actor.
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum PanicReason {
/// A message handler panicked during execution.
///
/// This occurs when an actor's [`Message::handle`](crate::message::Message::handle)
/// implementation panics or unwinds.
HandlerPanic,
/// The `on_message` hook returned an error.
///
/// In the default implementation, this occurs when a message handler returns
/// an error during a [`tell`](crate::actor::ActorRef::tell) operation, where
/// there's no mechanism to return the error to the caller. However, if
/// [`Actor::on_message`] is overridden with
/// custom logic, this variant indicates that the custom implementation
/// returned an error.
OnMessage,
/// The [`on_start`](Actor::on_start) lifecycle hook returned an error.
OnStart,
/// The [`on_panic`](Actor::on_panic) lifecycle hook returned an error.
OnPanic,
/// The [`on_link_died`](Actor::on_link_died) lifecycle hook returned an error.
OnLinkDied,
/// The [`on_stop`](Actor::on_stop) lifecycle hook returned an error.
OnStop,
}

@tqwewe tqwewe added this to the 0.20.0 milestone Nov 14, 2025
@hnorkowski
Copy link
Contributor Author

Yes that looks great! Thanks for your kind replies and implementing it 😊 If I could I would approve it 😄

@tqwewe tqwewe merged commit 2925a08 into tqwewe:main Nov 14, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] - Allow users to configure whether an actor should panic when Actor::tell returns an Err(..)

2 participants