Better error message for parseUnits of non-strings (#981).
This commit is contained in:
parent
38a068bcea
commit
5abc2f36e2
@ -70,6 +70,9 @@ export function formatUnits(value: BigNumberish, unitName?: string | BigNumberis
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function parseUnits(value: string, unitName?: BigNumberish): BigNumber {
|
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") {
|
if (typeof(unitName) === "string") {
|
||||||
const index = names.indexOf(unitName);
|
const index = names.indexOf(unitName);
|
||||||
if (index !== -1) { unitName = 3 * index; }
|
if (index !== -1) { unitName = 3 * index; }
|
||||||
|
Loading…
Reference in New Issue
Block a user