add clean errors for read, re: #45

This commit is contained in:
Mark Thom
2018-08-26 20:34:43 -06:00
parent 5afa4a7848
commit 92e338861d
2 changed files with 25 additions and 3 deletions

View File

@@ -58,6 +58,11 @@ impl MachineError {
MachineError { stub, from: ErrorProvenance::Constructed }
}
pub(super) fn syntax_error(error: SyntaxError) -> Self {
let stub = functor!("syntax_error", 1, [heap_atom!(error.as_str())]);
MachineError { stub, from: ErrorProvenance::Received }
}
pub(super) fn domain_error(error: DomainError, culprit: Addr) -> Self {
let stub = functor!("domain_error", 2, [heap_atom!(error.as_str()),
HeapCellValue::Addr(culprit)]);
@@ -135,6 +140,19 @@ impl ValidType {
}
}
#[derive(Clone, Copy)]
pub enum SyntaxError {
ImpDepAtom
}
impl SyntaxError {
pub fn as_str(&self) -> &'static str {
match self {
SyntaxError::ImpDepAtom => "imp_dep_atom"
}
}
}
#[derive(Clone, Copy)]
pub enum DomainError {
NotLessThanZero