stak_file/primitive_set/
error.rs1use crate::FileError;
2use core::{
3 error,
4 fmt::{self, Debug, Display, Formatter},
5};
6use stak_vm::Exception;
7
8#[derive(Clone, Debug, Eq, PartialEq)]
10pub enum PrimitiveError {
11 File(FileError),
13 Vm(stak_vm::Error),
15}
16
17impl Exception for PrimitiveError {
18 fn is_critical(&self) -> bool {
19 match self {
20 Self::File(_) => false,
21 Self::Vm(error) => error.is_critical(),
22 }
23 }
24}
25
26impl error::Error for PrimitiveError {}
27
28impl Display for PrimitiveError {
29 fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
30 match self {
31 Self::File(error) => write!(formatter, "{error}"),
32 Self::Vm(error) => write!(formatter, "{error}"),
33 }
34 }
35}
36
37impl From<FileError> for PrimitiveError {
38 fn from(error: FileError) -> Self {
39 Self::File(error)
40 }
41}
42
43impl From<stak_vm::Error> for PrimitiveError {
44 fn from(error: stak_vm::Error) -> Self {
45 Self::Vm(error)
46 }
47}