tasks: make error a json
also, handle case where we never got to handle task exit cleanly
This commit is contained in:
@@ -13,7 +13,7 @@ let assert = require('assert'),
|
||||
DatabaseError = require('./databaseerror'),
|
||||
safe = require('safetydance');
|
||||
|
||||
const TASKS_FIELDS = [ 'id', 'type', 'argsJson', 'percent', 'message', 'errorMessage', 'creationTime', 'resultJson', 'ts' ];
|
||||
const TASKS_FIELDS = [ 'id', 'type', 'argsJson', 'percent', 'message', 'errorJson', 'creationTime', 'resultJson', 'ts' ];
|
||||
|
||||
function postProcess(task) {
|
||||
assert.strictEqual(typeof task, 'object');
|
||||
@@ -26,6 +26,9 @@ function postProcess(task) {
|
||||
|
||||
task.result = JSON.parse(task.resultJson);
|
||||
delete task.resultJson;
|
||||
|
||||
task.error = safe.JSON.parse(task.errorJson);
|
||||
delete task.errorJson;
|
||||
}
|
||||
|
||||
function add(task, callback) {
|
||||
@@ -50,8 +53,8 @@ function update(id, data, callback) {
|
||||
let args = [ ];
|
||||
let fields = [ ];
|
||||
for (let k in data) {
|
||||
if (k === 'result') {
|
||||
fields.push('resultJson = ?');
|
||||
if (k === 'result' || k === 'error') {
|
||||
fields.push(`${k}Json = ?`);
|
||||
args.push(JSON.stringify(data[k]));
|
||||
} else {
|
||||
fields.push(k + ' = ?');
|
||||
|
||||
Reference in New Issue
Block a user