Catch bad spawn

This commit is contained in:
Bryan Ashby 2018-11-21 21:24:11 -07:00
parent 0721a7201c
commit ec1ce3062e
1 changed files with 9 additions and 1 deletions

View File

@ -5,6 +5,7 @@
const PluginModule = require('./plugin_module.js').PluginModule;
const Config = require('./config.js').get;
const Log = require('./logger.js').log;
const { Errors } = require('./enig_error.js');
const _ = require('lodash');
const later = require('later');
@ -138,7 +139,14 @@ class ScheduledEvent {
env : process.env,
};
const proc = pty.spawn(this.action.what, this.action.args, opts);
let proc;
try {
proc = pty.spawn(this.action.what, this.action.args, opts);
} catch(e) {
return cb(Errors.ExternalProcess(
`Error spawning @execute process "${this.action.what}" with args "${this.action.args.join(' ')}": ${e.message}`)
);
}
proc.once('exit', exitCode => {
if(exitCode) {