Skip to content

Commit

Permalink
Merge pull request #74 from Runnable/assert-on-publish
Browse files Browse the repository at this point in the history
update error name
  • Loading branch information
anandkumarpatel authored Aug 18, 2016
2 parents e364cc3 + 7d109f2 commit acb2c07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/rabbitmq.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class RabbitMQ {
const bufferContent = this._validatePublish(queue, content)
this.log.trace({ queue: queueName, job: content }, 'Publishing job')
if (!~this.tasks.indexOf(queue)) {
throw new Error('Trying to publish task not defined in constructor')
throw new Error(`task: "${queue}" not defined in constructor`)
}
return Promise.resolve(
this.publishChannel.sendToQueue(queueName, bufferContent)
Expand All @@ -267,7 +267,7 @@ class RabbitMQ {
return Promise.try(() => {
const bufferContent = this._validatePublish(exchange, content)
if (!~this.events.indexOf(exchange)) {
throw new Error('Trying to publish event not defined in constructor')
throw new Error(`event "${exchange}" not defined in constructor`)
}
// events do not need a routing key (so we send '')
return Promise.resolve(
Expand Down
6 changes: 3 additions & 3 deletions test/unit/rabbitmq.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ describe('rabbitmq', () => {
it('should reject if not defined', () => {
return assert.isRejected(
rabbitmq.publishTask('not-real', mockJob),
/Trying to publish task not defined in constructor/
/task: "not-real" not defined in constructor/
)
})

Expand Down Expand Up @@ -602,8 +602,8 @@ describe('rabbitmq', () => {

it('should reject if not defined', () => {
return assert.isRejected(
rabbitmq.publishEvent('not-real', mockJob),
/Trying to publish event not defined in constructor/
rabbitmq.publishEvent('unreal', mockJob),
/event "unreal" not defined in constructor/
)
})

Expand Down

0 comments on commit acb2c07

Please sign in to comment.