Errors
Error types returned by actor operations.
MailboxError
Error type returned when sending messages to actors fails.
Variants
MailboxClosedThe actor has stopped and its mailbox is closed. No more messages can be delivered.
Common Causes
- -Actor called ctx.stop()
- -Actor panicked during message handling
- -Parent actor stopped (for child actors)
- -System shutdown was called
TimeoutThe operation exceeded the specified timeout duration.
Common Causes
- -Actor is overloaded and processing slowly
- -Actor is blocked on I/O
- -Deadlock in message handling
MailboxFullThe actor's mailbox is at capacity. Only returned by try_send methods.
Common Causes
- -Actor processing messages slower than receiving
- -Mailbox capacity too small for workload
- -Actor blocked on slow operation
Error Handling Patterns
Propagate with ?
Match and Handle
Graceful Degradation
Circuit Breaker
Best Practices
Always handle MailboxClosed
Actors can stop at any time. Check is_alive() or handle the error to avoid sending to dead actors.
Use timeouts for external calls
When calling actors that perform I/O, use send_timeout to prevent indefinite blocking.
Use try_send for non-critical messages
For notifications, metrics, or other non-essential messages, use try_send to avoid back-pressure.
Size mailboxes appropriately
MailboxFull indicates the producer is faster than the consumer. Increase capacity or add more consumers.
Log and monitor errors
Track mailbox errors to identify overloaded actors or system issues.
