in src/Dgeni.ts [189:220]
runProcessor(processor, docs) {
const log = this.injector.get('log');
const promise = Promise.resolve(docs);
if ( !processor.$process ) {
return promise;
}
return promise
.then(() => {
log.info('running processor:', processor.name);
return this.triggerProcessorEvent('processorStart', processor, docs);
})
// We need to wrap this $process call in a new promise handler so that we can catch
// errors triggered by exceptions thrown in the $process method
// before they reach the promise handlers
.then(docs => processor.$process(docs) || docs)
.then(docs => this.triggerProcessorEvent('processorEnd', processor, docs))
.catch((error) => {
error.message = 'Error running processor "' + processor.name + '":\n' + error.message;
if ( this.stopOnProcessingError ) {
return Promise.reject(error);
} else {
log.error(error.message);
}
return docs;
});
}