From 653cbf8770d983c6def841c3591287aaf7053761 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Mon, 1 Oct 2018 00:24:56 -0400 Subject: [PATCH] Default to 500 error This is not production ready code. --- middleware/sendJSON.js | 2 +- test/unit/middleware/sendJSON.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/middleware/sendJSON.js b/middleware/sendJSON.js index 584fdf0e..3ae0a029 100644 --- a/middleware/sendJSON.js +++ b/middleware/sendJSON.js @@ -25,7 +25,7 @@ function sendJSONResponse(req, res, next) { if( check.array( geocoding.errors ) && geocoding.errors.length ){ // default status for errors is 400 Bad Request - statusCode = 400; // 400 Bad Request + statusCode = 500; // 400 Bad Request // iterate over all reported errors geocoding.errors.forEach( function( err ){ diff --git a/test/unit/middleware/sendJSON.js b/test/unit/middleware/sendJSON.js index d02138ff..6df1e431 100644 --- a/test/unit/middleware/sendJSON.js +++ b/test/unit/middleware/sendJSON.js @@ -70,7 +70,7 @@ module.exports.tests.default_error_status = function(test, common) { res.status = function( code ){ 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.end(); }}; @@ -124,7 +124,7 @@ module.exports.tests.request_timeout = function(test, common) { res.status = function( code ){ return { json: function( body ){ - t.equal( code, 408, 'Request Timeout' ); + t.equal( code, 500, 'Request Timeout' ); t.deepEqual( body, res.body, 'body set' ); t.end(); }}; @@ -214,7 +214,7 @@ module.exports.tests.unknown_exception = function(test, common) { res.status = function( code ){ 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.end(); }};