Skip to content

Commit

Permalink
Improve unhandled error copy (#17)
Browse files Browse the repository at this point in the history
* improved unhandled and unexpected error messages

* updated tests
  • Loading branch information
carolshark authored Oct 2, 2018
1 parent aa542ed commit d0bea3b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Platform (config) {
}
Platform.prototype.handleError = function (event, e) {
if (event.name === 'event' || (event.name === 'route' && this.req.job)) {
return this.res.job_fail('Unhandled Exception', e.message || 'Unhandled Exception', e)
return this.res.job_fail('Failed', e.message || 'unhandled_error', e)
}
if (event.name === 'route') {
return this.res.error(e)
Expand Down
2 changes: 1 addition & 1 deletion lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Response = (function () {
Response.prototype.job_fail = function (status, msg, data) {
this.meta('set_job_status', 'failed')
this.meta('set_job_status_message', status)
this.meta('set_job_failure_message', msg)
this.meta('set_job_failure_message', msg || 'unexpected_error')
if (data) {
this._respond(errorToObject(data))
}
Expand Down
4 changes: 2 additions & 2 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe('index', function () {
expect(context.succeed).to.have.been.called()
let args = context.succeed.args[0][0]
expect(args.meta.set_job_status).to.equal('failed')
expect(args.meta.set_job_status_message).to.equal('Unhandled Exception')
expect(args.meta.set_job_status_message).to.equal('Failed')
expect(args.meta.set_job_failure_message).to.equal('no')
expect(args.body.message).to.equal('no')
})
Expand All @@ -250,7 +250,7 @@ describe('index', function () {
expect(context.succeed).to.have.been.called()
let args = context.succeed.args[0][0]
expect(args.meta.set_job_status).to.equal('failed')
expect(args.meta.set_job_status_message).to.equal('Unhandled Exception')
expect(args.meta.set_job_status_message).to.equal('Failed')
expect(args.meta.set_job_failure_message).to.equal('no')
expect(args.body.message).to.equal('no')
done()
Expand Down

0 comments on commit d0bea3b

Please sign in to comment.