From adc554f925ed81a813552b9fce8ade89b98aa700 Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Thu, 6 Dec 2018 12:02:52 +0200 Subject: [PATCH] fix(core-json-rpc): return 404 if the last block is not found This should never happen unless, obviously, your node is not synced. --- packages/core-json-rpc/lib/server/methods/blocks/latest.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core-json-rpc/lib/server/methods/blocks/latest.js b/packages/core-json-rpc/lib/server/methods/blocks/latest.js index 07196d78b8..7375e84620 100644 --- a/packages/core-json-rpc/lib/server/methods/blocks/latest.js +++ b/packages/core-json-rpc/lib/server/methods/blocks/latest.js @@ -1,3 +1,4 @@ +const Boom = require('boom') const network = require('../../services/network') module.exports = { @@ -7,6 +8,8 @@ module.exports = { 'blocks?orderBy=height:desc&limit=1', ) - return response.data[0] + return response + ? response.data[0] + : Boom.notFound(`Latest block could not be found.`) }, }