Skip to content

Misleading error when too many arguments or missing arguments #3809

@zemse

Description

@zemse

Describe the Feature

Currently, if there is an invalid argument count, then ethers v6 throws an error that says "no matching function". However, it can point the dev to look in the wrong direction, i.e. check if ABI being passed is correct.

Error: no matching fragment (operation="fragment", code=UNSUPPORTED_OPERATION, version=6.0.5)

But if a more helpful error is thrown, it can be helpful to immediately point out that the issue is in the arguments somewhere, similar to the error in ethers v5 which says expected argument count is 1 but passed is 2.

Error: too many arguments: passed to contract (count=2, expectedCount=1, code=UNEXPECTED_ARGUMENT, version=contracts/5.5.0)

Code Example

await dai.balanceOf(ZeroAddress)
// works

await dai.balanceOf(ZeroAddress, 0)
// Error: no matching fragment (operation="fragment", code=UNSUPPORTED_OPERATION, version=6.0.5)

await dai.balanceOf()
// Error: no matching fragment (operation="fragment", code=UNSUPPORTED_OPERATION, version=6.0.5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement.v6Issues regarding v6

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions