Initial support for job queue
This commit is contained in:
parent
1238cca538
commit
bbd7fd3854
22 changed files with 1708 additions and 28 deletions
22
ts/jobs/JobError.ts
Normal file
22
ts/jobs/JobError.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { reallyJsonStringify } from '../util/reallyJsonStringify';
|
||||
|
||||
/**
|
||||
* An error that wraps job errors.
|
||||
*
|
||||
* Should not be instantiated directly, except by `JobQueue`.
|
||||
*/
|
||||
export class JobError extends Error {
|
||||
constructor(public readonly lastErrorThrownByJob: unknown) {
|
||||
super(`Job failed. Last error: ${formatError(lastErrorThrownByJob)}`);
|
||||
}
|
||||
}
|
||||
|
||||
function formatError(err: unknown): string {
|
||||
if (err instanceof Error) {
|
||||
return err.message;
|
||||
}
|
||||
return reallyJsonStringify(err);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue