Skip to content

Commit

Permalink
Merge pull request #156 from UKHomeOffice/error-status
Browse files Browse the repository at this point in the history
Send correct method not supported error and status
  • Loading branch information
HughePaul authored Jul 15, 2020
2 parents 3d44ce1 + 1568f0a commit e633808
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class BaseController {
methodNotSupported(req, res, next) {
debug('%s #methodNotSupported', req.originalUrl);
let err = new Error('Method not supported');
err.statusCode = 405;
err.code = 'METHOD_NOT_SUPPORTED';
err.status = 405;
next(err);
}

Expand Down
3 changes: 2 additions & 1 deletion test/controller/spec.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ describe('Form Controller', () => {
controller.methodNotSupported(req, res, next);
next.should.have.been.called.and.calledWithExactly(sinon.match.instanceOf(Error));
let err = next.args[0][0];
err.statusCode.should.equal(405);
err.status.should.equal(405);
err.code.should.equal('METHOD_NOT_SUPPORTED');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/controller/spec.lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('Controller Lifecycle', () => {
next.should.have.been.called;
let err = next.args[0][0];
err.should.be.instanceOf(Error);
err.statusCode.should.equal(405);
err.status.should.equal(405);
done();
};

Expand Down

0 comments on commit e633808

Please sign in to comment.