Skip to content

Commit

Permalink
Better error message for parseUnits of non-strings (#981).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Oct 7, 2020
1 parent 38a068b commit 5abc2f3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/units/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export function formatUnits(value: BigNumberish, unitName?: string | BigNumberis
}

export function parseUnits(value: string, unitName?: BigNumberish): BigNumber {
if (typeof(value) !== "string") {
logger.throwArgumentError("value must be a string", "value", value);
}
if (typeof(unitName) === "string") {
const index = names.indexOf(unitName);
if (index !== -1) { unitName = 3 * index; }
Expand Down

0 comments on commit 5abc2f3

Please # to comment.