quickjs_rusty/errors/
context_error.rs

1use std::{error, fmt};
2
3use super::ExecutionError;
4
5/// Error on context creation.
6#[derive(Debug)]
7pub enum ContextError {
8    /// Runtime could not be created.
9    RuntimeCreationFailed,
10    /// Context could not be created.
11    ContextCreationFailed,
12    /// Execution error while building.
13    Execution(ExecutionError),
14    #[doc(hidden)]
15    __NonExhaustive,
16}
17
18impl fmt::Display for ContextError {
19    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
20        use ContextError::*;
21        match self {
22            RuntimeCreationFailed => write!(f, "Could not create runtime"),
23            ContextCreationFailed => write!(f, "Could not create context"),
24            Execution(e) => e.fmt(f),
25            __NonExhaustive => unreachable!(),
26        }
27    }
28}
29
30impl error::Error for ContextError {}