You can catch errors by error.code
. Available codes are:
diFactory.Error.COULD_NOT_REQUIRE
- exception whilerequire(filename)
infile(filename)
orregister().file(filename)
diFactory.Error.NOT_A_FUNCTION
- exception whilefn()
inregister().factory(fn)
orinvoke(fn)
diFactory.Error.DEPENDENCY_NOT_FOUND
- exception ininvoke(fn)
orrequire(name)
var di = diFactory('app');
di.file('/my/file.js', null, function(error) {
if(error.code === diFactory.Error.COULD_NOT_REQUIRE) {
// just emit a warning if require failed, but keep the process alive
logger.warn(error.message);
return;
}
// throw every other error
throw error;
});