stak_time/primitive_set/
error.rs1use core::{
2 error,
3 fmt::{self, Debug, Display, Formatter},
4};
5use stak_vm::Exception;
6
7#[derive(Clone, Debug, Eq, PartialEq)]
9pub enum PrimitiveError {
10 CurrentJiffy,
12 Vm(stak_vm::Error),
14}
15
16impl Exception for PrimitiveError {
17 fn is_critical(&self) -> bool {
18 match self {
19 Self::CurrentJiffy => false,
20 Self::Vm(error) => error.is_critical(),
21 }
22 }
23}
24
25impl error::Error for PrimitiveError {}
26
27impl Display for PrimitiveError {
28 fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
29 match self {
30 Self::CurrentJiffy => write!(formatter, "failed to get current jiffy"),
31 Self::Vm(error) => write!(formatter, "{error}"),
32 }
33 }
34}
35
36impl From<stak_vm::Error> for PrimitiveError {
37 fn from(error: stak_vm::Error) -> Self {
38 Self::Vm(error)
39 }
40}