Skip to main content

starlang_runtime/
error.rs

1//! Error types for runtime operations.
2
3use starlang_core::Pid;
4use thiserror::Error;
5
6/// Errors that can occur during runtime operations.
7#[derive(Debug, Error)]
8pub enum RuntimeError {
9    /// Process not found in registry.
10    #[error("process not found: {0}")]
11    ProcessNotFound(Pid),
12
13    /// Failed to send a message.
14    #[error("send failed: {0}")]
15    SendFailed(#[from] SendError),
16
17    /// Failed to spawn a process.
18    #[error("spawn failed: {0}")]
19    SpawnFailed(#[from] SpawnError),
20}
21
22/// Errors that can occur when sending messages.
23#[derive(Debug, Error)]
24pub enum SendError {
25    /// The target process does not exist.
26    #[error("process not found: {0}")]
27    ProcessNotFound(Pid),
28
29    /// The mailbox is full (bounded channels only).
30    #[error("mailbox full")]
31    MailboxFull,
32
33    /// The process has terminated.
34    #[error("process terminated")]
35    ProcessTerminated,
36}
37
38/// Errors that can occur when spawning processes.
39#[derive(Debug, Error)]
40pub enum SpawnError {
41    /// Failed to create the process task.
42    #[error("failed to create process task: {0}")]
43    TaskCreationFailed(String),
44
45    /// Process initialization failed.
46    #[error("process initialization failed: {0}")]
47    InitFailed(String),
48}