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,
@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);
}

Loading…
Cancel
Save