Files
not-python/src/vm/error.rs
Alek Ratzloff 902da3f2f3 Add internal error handling to VM, plus function arity
* 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>
2020-10-13 14:07:22 -07:00

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>;