Skip to content

Commit

Permalink
FX service handles null results from calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
Cayle Sharrock committed Nov 11, 2017
1 parent df7c5d2 commit fa8ff4f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/FXService/FXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ export class FXService extends EventEmitter {
return this.calculator.calculateRatesFor(this.currencyPairs).then((rates: FXObject[]) => {
assert(Array.isArray(rates));
rates.forEach((rate: FXObject) => {
if (!rate) {
this.log('warn', 'The FX calculator returned null for latest FX query');
this.errorState = true;
return;
}
const index: string = pairAsString(rate);
const oldRate: FXObject = this.rates[index];
assert.equal(oldRate.from, rate.from, `The provided exchange rate has a base currency of ${rate.from} instead of ${oldRate.from}`);
Expand Down

0 comments on commit fa8ff4f

Please sign in to comment.