Browse Source

Default to 500 error

This is not production ready code.
default-500-err
Julian Simioni 6 years ago
parent
commit
653cbf8770
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 2
      middleware/sendJSON.js
  2. 6
      test/unit/middleware/sendJSON.js

2
middleware/sendJSON.js

@ -25,7 +25,7 @@ function sendJSONResponse(req, res, next) {
if( check.array( geocoding.errors ) && geocoding.errors.length ){ if( check.array( geocoding.errors ) && geocoding.errors.length ){
// default status for errors is 400 Bad Request // default status for errors is 400 Bad Request
statusCode = 400; // 400 Bad Request statusCode = 500; // 400 Bad Request
// iterate over all reported errors // iterate over all reported errors
geocoding.errors.forEach( function( err ){ geocoding.errors.forEach( function( err ){

6
test/unit/middleware/sendJSON.js

@ -70,7 +70,7 @@ module.exports.tests.default_error_status = function(test, common) {
res.status = function( code ){ res.status = function( code ){
return { json: function( body ){ return { json: function( body ){
t.equal( code, 400, '400 Bad Request' ); t.equal( code, 500, '400 Bad Request' );
t.deepEqual( body, res.body, 'body set' ); t.deepEqual( body, res.body, 'body set' );
t.end(); t.end();
}}; }};
@ -124,7 +124,7 @@ module.exports.tests.request_timeout = function(test, common) {
res.status = function( code ){ res.status = function( code ){
return { json: function( body ){ return { json: function( body ){
t.equal( code, 408, 'Request Timeout' ); t.equal( code, 500, 'Request Timeout' );
t.deepEqual( body, res.body, 'body set' ); t.deepEqual( body, res.body, 'body set' );
t.end(); t.end();
}}; }};
@ -214,7 +214,7 @@ module.exports.tests.unknown_exception = function(test, common) {
res.status = function( code ){ res.status = function( code ){
return { json: function( body ){ return { json: function( body ){
t.equal( code, 400, '400 Bad Request' ); t.equal( code, 500, '400 Bad Request' );
t.deepEqual( body, res.body, 'body set' ); t.deepEqual( body, res.body, 'body set' );
t.end(); t.end();
}}; }};

Loading…
Cancel
Save