From 8f9b8f779fb69414fef72a93d569a250fcf5c668 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 28 May 2015 11:03:57 -0400 Subject: [PATCH] JsonResponse retain output value on request error --- src/dapi/format/JsonResponse.js | 2 +- test/dapi/format/JsonResponseTest.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dapi/format/JsonResponse.js b/src/dapi/format/JsonResponse.js index d0f08fe..49ebe9e 100644 --- a/src/dapi/format/JsonResponse.js +++ b/src/dapi/format/JsonResponse.js @@ -49,7 +49,7 @@ module.exports = Trait( 'JsonResponse' ) { if ( err !== null ) { - callback( err, null ); + callback( err, resp ); return; } diff --git a/test/dapi/format/JsonResponseTest.js b/test/dapi/format/JsonResponseTest.js index 6360562..633a93f 100644 --- a/test/dapi/format/JsonResponseTest.js +++ b/test/dapi/format/JsonResponseTest.js @@ -85,14 +85,15 @@ describe( 'dapi.format.JsonRepsonse trait', function() it( 'proxy error from encapsulated DataApi', function( done ) { - var e = Error( 'foo' ); + var e = Error( 'foo' ), + chk = {}; - _createStubbedDapi( e, '0' ) + _createStubbedDapi( e, chk ) .request( '', function( err, data ) { // data should also be cleared out expect( err ).to.equal( e ); - expect( data ).to.equal( null ); + expect( data ).to.equal( chk ); done(); } ); } );