-
Notifications
You must be signed in to change notification settings - Fork 16
Error Handling
Whilst using rethinkdb-job-queue
errors may occur. There are two ways you can handle errors within your code; Promise catch method or error events.
If you are calling a method on either a Queue object or a Job object that returns a Promise, you can and should add a catch()
method onto the Promise chain so you can log errors that occur.
Rather than list the Queue or Job objects methods that return a Promise, it is easier to list the methods that do not return a Promise.
The following list of object methods do not return a Promise.
All other Queue and Job object methods will return a Promise.
This example will catch errors that occur when adding a job to the queue.
const Queue = require('rethinkdb-job-queue')
const q = new Queue()
let job = q.createJob({ data: 'foo' })
q.addJob(job).catch(err => console.error(err))
When you create your Queue object you can subscribe to the error event and log or respond to errors within the callback method. The error object will contain an extra property queueId
to help identify the Queue object involved in raising the error.
This example will log all errors that occur within the Queue object.
const Queue = require('rethinkdb-job-queue')
const q = new Queue()
q.on('error', (err) => {
console.log('Queue Id: ' + err.queueId)
console.error(err)
})
- Introduction
- Tutorial
- Queue Constructor
- Queue Connection
- Queue Options
- Queue PubSub
- Queue Master
- Queue Events
- State Document
- Job Processing
- Job Options
- Job Status
- Job Retry
- Job Repeat
- Job Logging
- Job Editing
- Job Schema
- Job Name
- Complex Job
- Delayed Job
- Cancel Job
- Error Handling
- Queue.createJob
- Queue.addJob
- Queue.getJob
- Queue.findJob
- Queue.findJobByName
- Queue.containsJobByName
- Queue.cancelJob
- Queue.reanimateJob
- Queue.removeJob
- Queue.process
- Queue.review
- Queue.summary
- Queue.ready
- Queue.pause
- Queue.resume
- Queue.reset
- Queue.stop
- Queue.drop
- Queue.Job
- Queue.host
- Queue.port
- Queue.db
- Queue.name
- Queue.r
- Queue.id
- Queue.jobOptions [R/W]
- Queue.changeFeed
- Queue.master
- Queue.masterInterval
- Queue.removeFinishedJobs
- Queue.running
- Queue.concurrency [R/W]
- Queue.paused
- Queue.idle
- Event.ready
- Event.added
- Event.updated
- Event.active
- Event.processing
- Event.progress
- Event.log
- Event.pausing
- Event.paused
- Event.resumed
- Event.completed
- Event.cancelled
- Event.failed
- Event.terminated
- Event.reanimated
- Event.removed
- Event.idle
- Event.reset
- Event.error
- Event.reviewed
- Event.detached
- Event.stopping
- Event.stopped
- Event.dropped
- Job.setName
- Job.setPriority
- Job.setTimeout
- Job.setDateEnable
- Job.setRetryMax
- Job.setRetryDelay
- Job.setRepeat
- Job.setRepeatDelay
- Job.updateProgress
- Job.update
- Job.getCleanCopy
- Job.addLog
- Job.getLastLog