Skip to content

Commit

Permalink
feat: log errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Nov 26, 2020
1 parent 9acc9b4 commit 011ac87
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"@types/roarr": "^2.14.2",
"@types/set-interval-async": "^1.0.0",
"es6-error": "^4.1.1",
"roarr": "^2.15.4"
"roarr": "^2.15.4",
"serialize-error": "^7.0.1"
},
"description": "Database-agnostic task scheduler.",
"devDependencies": {
Expand Down
18 changes: 18 additions & 0 deletions src/factories/createPlanton.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import delay from 'delay';
import {
serializeError,
} from 'serialize-error';
import Logger from '../Logger';
import {
UnexpectedTaskInstructionsError,
Expand Down Expand Up @@ -120,6 +123,11 @@ const createPlanton = (configuration: PlantonConfigurationInput): Planton => {
limit: concurrency - activeTaskInstructions.length,
});
} catch (error) {
log.error({
error: serializeError(error),
taskName: task.name,
}, 'scheduler produced an error');

events.emit('error', {
error,
taskName: task.name || '',
Expand All @@ -134,6 +142,11 @@ const createPlanton = (configuration: PlantonConfigurationInput): Planton => {
taskName: task.name || '',
});

log.error({
taskInstructions,
taskName: task.name,
}, 'scheduler produced an unexpected result; result is not array');

taskInstructions = [];
}

Expand All @@ -144,6 +157,11 @@ const createPlanton = (configuration: PlantonConfigurationInput): Planton => {
taskName: task.name || '',
});

log.error({
taskInstructions,
taskName: task.name,
}, 'scheduler produced an unexpected result; array members are not string');

taskInstructions = [];

break;
Expand Down

0 comments on commit 011ac87

Please sign in to comment.