Skip to content

Commit

Permalink
timer: add error handler for case when a transport isn't defined
Browse files Browse the repository at this point in the history
  • Loading branch information
esatterwhite committed Jun 2, 2017
1 parent 014bd16 commit ab16242
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ timers.create(id, options, (err) => {
create(id, body, cb) {
const payload = body;
const transport = this.transports[payload.callback.transport];
if (!transport) {
const err = new Error(`Unknown transport ${payload.callback.transport}`)
err.code = 'ENOTRANSPORT'
return setImmediate(cb, err)
}
if ( this.has( id ) ) {
const err = new Error(`Timer with id ${id} already exists` );
err.code = 'EKEYEXISTS';
Expand Down

0 comments on commit ab16242

Please sign in to comment.