From 4b5aeb961eafbf84c3fef83ae4a34412d4c21c07 Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Mon, 25 Dec 2023 13:20:51 +0100 Subject: [PATCH] Added error handling when bid suggestion call fails --- .../v0/bid-suggestion-http-api-controller-v0.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/controllers/http-api/v0/bid-suggestion-http-api-controller-v0.js b/src/controllers/http-api/v0/bid-suggestion-http-api-controller-v0.js index e41932c32b..3a1905e708 100644 --- a/src/controllers/http-api/v0/bid-suggestion-http-api-controller-v0.js +++ b/src/controllers/http-api/v0/bid-suggestion-http-api-controller-v0.js @@ -45,17 +45,24 @@ class BidSuggestionController extends BaseController { firstAssertionId, hashFunctionId, } = req.query; - - this.returnResponse(res, 200, { - bidSuggestion: await this.shardingTableService.getBidSuggestion( + try { + const bidSuggestion = await this.shardingTableService.getBidSuggestion( blockchain, epochsNumber, assertionSize, contentAssetStorageAddress, firstAssertionId, hashFunctionId, - ), - }); + ); + + this.returnResponse(res, 200, { bidSuggestion }); + } catch (error) { + this.logger.error(`Unable to get bid suggestion. Error: ${error}`); + this.returnResponse(res, 500, { + code: 500, + message: 'Unable to calculate bid suggestion', + }); + } } }