Fix consultRules so that it does not bail out on RuntimeException

This problem was causing internal server error in Gerrit GUI on browsing
open changes in case one or more projects had broken rules.pl in meta
config.

Change-Id: Ib1395a5d48abd0150a9b2e0c3680cb39ae186f1a
Signed-off-by: Eryk Szymanski <eryksz@gmail.com>
This commit is contained in:
Eryk Szymanski 2014-06-19 14:36:14 +02:00
parent 6e381a26e7
commit ea1f69d5e3
1 changed files with 9 additions and 6 deletions

View File

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