Skip to content

Commit

Permalink
test super error on fatal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech committed Mar 19, 2017
1 parent def11a1 commit ac0c6ec
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/hemera/index.spec.js
Expand Up @@ -3537,6 +3537,42 @@ describe('Response error events', function () {
})
})

it('client response error result with a custom super error', function (done) {
const nats = require('nats').connect(authUrl)

const hemera = new Hemera(nats, {
crashOnFatal: false
})

hemera.ready(() => {
hemera.on('clientResponseError', function (err) {
expect(err).to.be.exists()
expect(err.name).to.be.equals('FatalError')
expect(err.message).to.be.equals('Fatal error')
expect(err.cause.name).to.be.equals('Unauthorized')
expect(err.cause.message).to.be.equals('test')
hemera.close()
done()
})

hemera.add({
cmd: 'add',
topic: 'math'
}, (resp, cb) => {
cb()
})

hemera.act({
topic: 'math',
cmd: 'add',
a: 1,
b: 2
}, function () {
throw new UnauthorizedError('test')
})
})
})

it('client response extension error', function (done) {
const nats = require('nats').connect(authUrl)

Expand Down

0 comments on commit ac0c6ec

Please sign in to comment.