add top level exception reporting, exceptions for call/N.

This commit is contained in:
Mark Thom
2017-08-17 18:20:58 -06:00
parent 1a7edc2d13
commit 02c0f1cf56
5 changed files with 165 additions and 95 deletions

View File

@@ -403,6 +403,10 @@ Each predicate must have the same name and arity.";
}
}
fn error_string(e: &String) -> String {
format!("error: {}", e)
}
pub fn print(wam: &mut Machine, result: EvalSession) {
match result {
EvalSession::InitialQuerySuccess(alloc_locs, mut heap_locs) => {
@@ -451,6 +455,12 @@ pub fn print(wam: &mut Machine, result: EvalSession) {
stdout.flush().unwrap();
return;
}
if let &EvalSession::QueryFailureWithException(ref e) = &result {
write!(stdout, "{}\n\r", error_string(e)).unwrap();
stdout.flush().unwrap();
return;
}
} else {
break;
}
@@ -459,6 +469,7 @@ pub fn print(wam: &mut Machine, result: EvalSession) {
write!(stdout(), ".\n").unwrap();
},
EvalSession::QueryFailure => println!("false."),
EvalSession::QueryFailureWithException(e) => println!("{}", error_string(&e)),
EvalSession::EntryFailure(msg) => println!("{}", msg),
_ => {}
};