add UnspecifiedWorkerError error
This commit is contained in:
@@ -9,4 +9,11 @@ errors.WorkerTimeoutError = typedError({
|
|||||||
jobId: null
|
jobId: null
|
||||||
});
|
});
|
||||||
|
|
||||||
|
errors.UnspecifiedWorkerError = typedError({
|
||||||
|
type: 'UnspecifiedWorkerError',
|
||||||
|
message: 'Unspecified worker error',
|
||||||
|
timeout: null,
|
||||||
|
jobId: null
|
||||||
|
});
|
||||||
|
|
||||||
export default errors;
|
export default errors;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Puid from 'puid';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import logger from './helpers/logger';
|
import logger from './helpers/logger';
|
||||||
import constants from './helpers/constants';
|
import constants from './helpers/constants';
|
||||||
import { WorkerTimeoutError } from './helpers/errors';
|
import { WorkerTimeoutError, UnspecifiedWorkerError } from './helpers/errors';
|
||||||
|
|
||||||
const puid = new Puid();
|
const puid = new Puid();
|
||||||
const debug = logger('esqueue:worker');
|
const debug = logger('esqueue:worker');
|
||||||
@@ -173,6 +173,12 @@ export default class Job extends events.EventEmitter {
|
|||||||
this.emit('job_error', err);
|
this.emit('job_error', err);
|
||||||
});
|
});
|
||||||
}, (jobErr) => {
|
}, (jobErr) => {
|
||||||
|
if (!jobErr) {
|
||||||
|
jobErr = new UnspecifiedWorkerError({
|
||||||
|
jobId: job._id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// job execution failed
|
// job execution failed
|
||||||
if (jobErr.type === 'WorkerTimeoutError') {
|
if (jobErr.type === 'WorkerTimeoutError') {
|
||||||
this.debug(`Timeout on job ${job._id}`);
|
this.debug(`Timeout on job ${job._id}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user