Skip to content

Commit

Permalink
Change error message
Browse files Browse the repository at this point in the history
  • Loading branch information
xxczaki committed Jan 19, 2020
1 parent 27056b8 commit b2617f3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/get-rate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {Rates} from './options';
* @param to Currency to which you want to convert.
* @return Conversion result.
*/
export default function getRate(base: string, rates: Rates, from: string | undefined, to: string): number {
if (from) {
export default function getRate(base: string, rates: Rates, from: string | undefined, to: string | undefined): number {
if (from && to) {
// If `from` equals `base`, return the basic exchange rate for the `to` currency
if (from === base && hasKey(rates, to)) {
return rates[to];
Expand All @@ -28,6 +28,6 @@ export default function getRate(base: string, rates: Rates, from: string | undef

throw new Error('`rates` object does not contain either `from` or `to` currency!');
} else {
throw new Error('Please specify the `from` currency!');
throw new Error('Please specify the `from` and/or `to` currency or use parsing!');
}
}

0 comments on commit b2617f3

Please sign in to comment.