Browse Source

Make details endpoint fault tolerant (do not throw error)

pull/302/head
Thomas 4 years ago
parent
commit
cb5d934585
  1. 15
      apps/api/src/app/portfolio/portfolio.controller.ts

15
apps/api/src/app/portfolio/portfolio.controller.ts

@ -125,17 +125,12 @@ export class PortfolioController {
@Query('range') range, @Query('range') range,
@Res() res: Response @Res() res: Response
): Promise<{ [symbol: string]: PortfolioPosition }> { ): Promise<{ [symbol: string]: PortfolioPosition }> {
let details: { [symbol: string]: PortfolioPosition } = {}; const { details, hasErrors } = await this.portfolioService.getDetails(
impersonationId,
try { range
details = await this.portfolioService.getDetails(impersonationId, range); );
} catch (error) {
console.error(error);
res.status(StatusCodes.ACCEPTED);
}
if (hasNotDefinedValuesInObject(details)) { if (hasErrors || hasNotDefinedValuesInObject(details)) {
res.status(StatusCodes.ACCEPTED); res.status(StatusCodes.ACCEPTED);
} }

Loading…
Cancel
Save