hermes_runtime/types/
error.rs1use alloc::sync::Arc;
2use core::fmt::Display;
3use core::str::Utf8Error;
4use std::error::Error;
5use std::io::Error as IoError;
6use std::process::ExitStatus;
7
8#[derive(Clone, Debug)]
9pub enum TokioRuntimeError {
10 ChannelClosed,
11 PoisonedLock,
12 Io(Arc<IoError>),
13 Utf8(Utf8Error),
14 PrematureChildProcessExit {
15 exit_status: ExitStatus,
16 stdout: String,
17 stderr: String,
18 },
19 ChildProcessExitFailure {
20 exit_status: ExitStatus,
21 },
22 ExecCommandFailure {
23 command: String,
24 exit_code: Option<i32>,
25 stdout: String,
26 stderr: String,
27 },
28}
29
30impl Display for TokioRuntimeError {
31 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
32 match self {
33 Self::ChannelClosed => {
34 write!(f, "unexpected closure of internal rust channels")?;
35 }
36 Self::PoisonedLock => {
37 write!(f, "poisoned mutex lock")?;
38 }
39 Self::Io(e) => {
40 write!(f, "{e}")?;
41 }
42 Self::Utf8(e) => {
43 write!(f, "{e}")?;
44 }
45 Self::PrematureChildProcessExit {
46 exit_status,
47 stderr,
48 ..
49 } => {
50 write!(f, "expected child process to be running, but it exited immediately with exit status {} and stderr: {}", exit_status, stderr)?;
51 }
52 Self::ExecCommandFailure {
53 command,
54 exit_code,
55 stderr,
56 ..
57 } => {
58 write!(
59 f,
60 "execution of command {} failed with exit code {:?}. stderr: {}",
61 command, exit_code, stderr
62 )?;
63 }
64 Self::ChildProcessExitFailure { exit_status } => {
65 write!(
66 f,
67 "child process exited with non-success status {}",
68 exit_status
69 )?;
70 }
71 };
72
73 Ok(())
74 }
75}
76
77impl Error for TokioRuntimeError {}