Catch ACS parse exception

This commit is contained in:
Bryan Ashby 2016-08-29 21:01:51 -06:00
parent ef7f6355c6
commit a54caed41e
1 changed files with 13 additions and 2 deletions

View File

@ -3,6 +3,7 @@
// ENiGMA½ // ENiGMA½
const checkAcs = require('./acs_parser.js').parse; const checkAcs = require('./acs_parser.js').parse;
const Log = require('./logger.js').log;
// deps // deps
const assert = require('assert'); const assert = require('assert');
@ -16,7 +17,12 @@ class ACS {
check(acs, scope, defaultAcs) { check(acs, scope, defaultAcs) {
acs = acs ? acs[scope] : defaultAcs; acs = acs ? acs[scope] : defaultAcs;
acs = acs || defaultAcs; acs = acs || defaultAcs;
try {
return checkAcs(acs, { client : this.client } ); return checkAcs(acs, { client : this.client } );
} catch(e) {
Log.warn( { exception : e, acs : acs }, 'Exception caught checking ACS');
return false;
}
} }
hasMessageConfRead(conf) { hasMessageConfRead(conf) {
@ -33,7 +39,12 @@ class ACS {
const matchCond = condArray.find( cond => { const matchCond = condArray.find( cond => {
if(_.has(cond, 'acs')) { if(_.has(cond, 'acs')) {
try {
return checkAcs(cond.acs, { client : this.client } ); return checkAcs(cond.acs, { client : this.client } );
} catch(e) {
Log.warn( { exception : e, acs : cond }, 'Exception caught checking ACS');
return false;
}
} else { } else {
return true; // no acs check req. return true; // no acs check req.
} }