diff --git a/src/apps.js b/src/apps.js index e06db3874..f14af0127 100644 --- a/src/apps.js +++ b/src/apps.js @@ -49,6 +49,10 @@ exports = module.exports = { PORT_TYPE_TCP: 'tcp', PORT_TYPE_UDP: 'udp', + // error codes + ETASK_STOPPED: 'task_stopped', // user stopped a task + ETASK_CRASHED: 'task_crashed', // apptask crashed + // exported for testing _validatePortBindings: validatePortBindings, _validateAccessRestriction: validateAccessRestriction, @@ -599,7 +603,8 @@ function scheduleTask(appId, args, values, callback) { debug(`scheduleTask: task ${taskId} of $${appId} completed`); if (error && (error.crashed || error.stopped)) { debug(`Apptask crashed/stopped: ${error.message}`); - appdb.update(appId, { installationState: appdb.ISTATE_ERROR, error: { message: error.message }, taskId: null }, NOOP_CALLBACK); + const code = error.crashed ? exports.ETASK_CRASHED : exports.ETASK_STOPPED; + appdb.update(appId, { installationState: appdb.ISTATE_ERROR, error: { code: code, message: error.message }, taskId: null }, NOOP_CALLBACK); } else if (values.installationState !== appdb.ISTATE_PENDING_UNINSTALL) { appdb.update(appId, { taskId: null }, NOOP_CALLBACK); }