* VM is able to handle basic runtime errors although there is no way to catch this in executing code currently * If a function is called with the wrong number of arguments (arity) it will invoke a runtime error. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
25 lines
549 B
Rust
25 lines
549 B
Rust
use crate::obj::prelude::*;
|
|
use snafu::Snafu;
|
|
|
|
#[derive(Debug, Snafu)]
|
|
pub enum Error {
|
|
#[snafu(display("missing attribute: {}", global_sym_lookup(*attr).unwrap()))]
|
|
MissingAttr {
|
|
attr: Sym,
|
|
},
|
|
|
|
#[snafu(display("{}", error))]
|
|
ValueError {
|
|
error: String,
|
|
value: ObjRef,
|
|
},
|
|
|
|
#[snafu(display("incorrect function arity; expected {} but got {} instead", expected, got))]
|
|
ArityError {
|
|
expected: usize,
|
|
got: usize,
|
|
},
|
|
}
|
|
|
|
pub type Result<T, E = Error> = std::result::Result<T, E>;
|