replace typed errors with custom errors

This commit is contained in:
2017-02-28 15:44:28 -07:00
parent 1e8340f214
commit 9cff4e4b04
2 changed files with 68 additions and 16 deletions

View File

@@ -1,19 +1,20 @@
import typedError from 'error/typed';
export function WorkerTimeoutError(message, props = {}) {
this.name = 'WorkerTimeoutError';
this.message = message;
this.timeout = props.timeout;
this.jobId = props.jobId;
const errors = {};
if ("captureStackTrace" in Error) Error.captureStackTrace(this, WorkerTimeoutError);
else this.stack = (new Error()).stack;
}
WorkerTimeoutError.prototype = Object.create(Error.prototype);
errors.WorkerTimeoutError = typedError({
type: 'WorkerTimeoutError',
message: 'worker timed out, timeout={timeout}',
timeout: null,
jobId: null
});
export function UnspecifiedWorkerError(message, props = {}) {
this.name = 'UnspecifiedWorkerError';
this.message = message;
this.jobId = props.jobId;
errors.UnspecifiedWorkerError = typedError({
type: 'UnspecifiedWorkerError',
message: 'Unspecified worker error',
timeout: null,
jobId: null
});
export default errors;
if ("captureStackTrace" in Error) Error.captureStackTrace(this, UnspecifiedWorkerError);
else this.stack = (new Error()).stack;
}
UnspecifiedWorkerError.prototype = Object.create(Error.prototype);