hermes_runtime/impls/runtime/
error.rs1use alloc::sync::Arc;
2use core::str::Utf8Error;
3use std::io::Error as IoError;
4use std::process::ExitStatus;
5
6use cgp::core::error::{ErrorRaiser, ProvideErrorType};
7use hermes_async_runtime_components::channel::types::ChannelClosedError;
8use hermes_tokio_runtime_components::impls::os::child_process::PrematureChildProcessExitError;
9use hermes_tokio_runtime_components::impls::os::exec_command::ExecCommandFailure;
10
11use crate::impls::runtime::components::HermesRuntimeComponents;
12use crate::types::error::TokioRuntimeError;
13use crate::types::runtime::HermesRuntime;
14
15impl ProvideErrorType<HermesRuntime> for HermesRuntimeComponents {
16 type Error = TokioRuntimeError;
17}
18
19impl ErrorRaiser<HermesRuntime, PrematureChildProcessExitError> for HermesRuntimeComponents {
20 fn raise_error(e: PrematureChildProcessExitError) -> TokioRuntimeError {
21 TokioRuntimeError::PrematureChildProcessExit {
22 exit_status: e.exit_status,
23 stdout: e.stdout,
24 stderr: e.stderr,
25 }
26 }
27}
28
29impl ErrorRaiser<HermesRuntime, ExitStatus> for HermesRuntimeComponents {
30 fn raise_error(exit_status: ExitStatus) -> TokioRuntimeError {
31 TokioRuntimeError::ChildProcessExitFailure { exit_status }
32 }
33}
34
35impl ErrorRaiser<HermesRuntime, IoError> for HermesRuntimeComponents {
36 fn raise_error(e: IoError) -> TokioRuntimeError {
37 TokioRuntimeError::Io(Arc::new(e))
38 }
39}
40
41impl ErrorRaiser<HermesRuntime, Utf8Error> for HermesRuntimeComponents {
42 fn raise_error(e: Utf8Error) -> TokioRuntimeError {
43 TokioRuntimeError::Utf8(e)
44 }
45}
46
47impl ErrorRaiser<HermesRuntime, ChannelClosedError> for HermesRuntimeComponents {
48 fn raise_error(_e: ChannelClosedError) -> TokioRuntimeError {
49 TokioRuntimeError::ChannelClosed
50 }
51}
52
53impl ErrorRaiser<HermesRuntime, ExecCommandFailure> for HermesRuntimeComponents {
54 fn raise_error(e: ExecCommandFailure) -> TokioRuntimeError {
55 TokioRuntimeError::ExecCommandFailure {
56 command: e.command,
57 exit_code: e.exit_code,
58 stdout: e.stdout,
59 stderr: e.stderr,
60 }
61 }
62}