From cb5d934585c2cad8eda0390f4ec88a5f6edab5cd Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Thu, 19 Aug 2021 21:38:42 +0200 Subject: [PATCH] Make details endpoint fault tolerant (do not throw error) --- .../api/src/app/portfolio/portfolio.controller.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 0646f9995..ce0e736ee 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -125,17 +125,12 @@ export class PortfolioController { @Query('range') range, @Res() res: Response ): Promise<{ [symbol: string]: PortfolioPosition }> { - let details: { [symbol: string]: PortfolioPosition } = {}; - - try { - details = await this.portfolioService.getDetails(impersonationId, range); - } catch (error) { - console.error(error); - - res.status(StatusCodes.ACCEPTED); - } + const { details, hasErrors } = await this.portfolioService.getDetails( + impersonationId, + range + ); - if (hasNotDefinedValuesInObject(details)) { + if (hasErrors || hasNotDefinedValuesInObject(details)) { res.status(StatusCodes.ACCEPTED); }