Skip to main content

zapcode_core/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum ZapcodeError {
5    #[error("parse error: {0}")]
6    ParseError(String),
7
8    #[error("unsupported syntax at {span}: {description}")]
9    UnsupportedSyntax { span: String, description: String },
10
11    #[error("compile error: {0}")]
12    CompileError(String),
13
14    #[error("runtime error: {0}")]
15    RuntimeError(String),
16
17    #[error("type error: {0}")]
18    TypeError(String),
19
20    #[error("reference error: {0} is not defined")]
21    ReferenceError(String),
22
23    #[error("unknown external function: {0}")]
24    UnknownExternalFunction(String),
25
26    #[error("memory limit exceeded: {0}")]
27    MemoryLimitExceeded(String),
28
29    #[error("execution time limit exceeded")]
30    TimeLimitExceeded,
31
32    #[error("stack overflow (depth {0})")]
33    StackOverflow(usize),
34
35    #[error("allocation limit exceeded")]
36    AllocationLimitExceeded,
37
38    #[error("snapshot error: {0}")]
39    SnapshotError(String),
40
41    #[error("sandbox violation: {0}")]
42    SandboxViolation(String),
43}
44
45pub type Result<T> = std::result::Result<T, ZapcodeError>;