CashScript / cashscript

⚖️ Easily write and interact with Bitcoin Cash smart contracts
https://cashscript.org
MIT License
112 stars 79 forks source link

More actionable error message for "Incorrect number of arguments" #118

Closed emergent-reasons closed 1 month ago

emergent-reasons commented 2 years ago

Example:

Incorrect number of arguments passed to AnyHedge_v0_11 constructor

Would be nice to have

Expected x arguments for y constructor but got z

or

X unexpected arguments and Y missing arguments passed to ... constructor

or any format that works.

mr-zwets commented 1 month ago

Just made a commit to the @next branch to improve the error message to provide more info 👍

Now it returns the error in this format:

Incorrect number of arguments passed to function spend. Expected 2 arguments (pubkey,sig) but got 0

Note that this is not exactly the suggested format as it's not trivial to return the provided types (because the provided types would be JS types instead of CashScript types).

I think we can close this old issue now, should it come up again we can reopen it 😄

emergent-reasons commented 1 month ago

Looks great!