Merge "Fix consultRules so that it does not bail out on RuntimeException" into stable-2.9

This commit is contained in:
Edwin Kempin 2014-06-23 12:24:21 +00:00 committed by Gerrit Code Review
commit 22da0b0a08
1 changed files with 9 additions and 6 deletions

View File

@ -196,14 +196,17 @@ public class RulesCache {
return pmc; return pmc;
} }
private PrologMachineCopy consultRules(String name, Reader rules) { private PrologMachineCopy consultRules(String name, Reader rules)
throws CompileException {
BufferingPrologControl ctl = newEmptyMachine(systemLoader); BufferingPrologControl ctl = newEmptyMachine(systemLoader);
PushbackReader in = new PushbackReader(rules, Prolog.PUSHBACK_SIZE); PushbackReader in = new PushbackReader(rules, Prolog.PUSHBACK_SIZE);
if (!ctl.execute( try {
Prolog.BUILTIN, "consult_stream", if (!ctl.execute(Prolog.BUILTIN, "consult_stream",
SymbolTerm.intern(name), SymbolTerm.intern(name), new JavaObjectTerm(in))) {
new JavaObjectTerm(in))) { return null;
return null; }
} catch (RuntimeException e) {
throw new CompileException("Error while consulting rules from " + name, e);
} }
return save(ctl); return save(ctl);
} }