Skip to content

Commit b2617f3

Browse files
committed
Change error message
1 parent 27056b8 commit b2617f3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib/get-rate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {Rates} from './options';
99
* @param to Currency to which you want to convert.
1010
* @return Conversion result.
1111
*/
12-
export default function getRate(base: string, rates: Rates, from: string | undefined, to: string): number {
13-
if (from) {
12+
export default function getRate(base: string, rates: Rates, from: string | undefined, to: string | undefined): number {
13+
if (from && to) {
1414
// If `from` equals `base`, return the basic exchange rate for the `to` currency
1515
if (from === base && hasKey(rates, to)) {
1616
return rates[to];
@@ -28,6 +28,6 @@ export default function getRate(base: string, rates: Rates, from: string | undef
2828

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

0 commit comments

Comments
 (0)