Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Error messages in all Contracts and Transactions to be more descriptive #795

Open
3 of 17 tasks
joshuahannan opened this issue Jun 3, 2024 · 0 comments
Open
3 of 17 tasks
Assignees

Comments

@joshuahannan
Copy link
Member

joshuahannan commented Jun 3, 2024

Issue to be solved

Error messages for panics in transactions and contracts are not very helpful to end-users.
They should be updated to be more descriptive.
We should also try to gear them to be able to be understood by regular users if possible so they can know how to fix them or what to say to whatever support person they are talking to

Suggest A Solution

Go through all the standard contracts, transactions, and scripts in every smart contract repo to update them with good error messages. Error messages could contain:

  • Contract name, resource name, and function name if coming from a contract
    • Example: ExampleToken.Vault.deposit: ..."
  • Description of literal error
  • Description of what high-level reason is causing the error
  • Suggestion for fixing it if applicable
  • If referring to a type that a regular user might understand like TopShot.Collection, use the format "TopShot Collection" or "FungibleToken Vault" instead of using . to make it less confusing to regular users who might see it
  • If including type values in the error message where the type is especially important or is a user-provided argument, use <> to contain the type
  • If including any other value type, try to phrase the error message so that the the value does not need to be contained in parentheses or an = sign. For example:
        let withdrawRef = signer.storage.borrow<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>(
                from: self.collectionData.storagePath
            ) ?? panic("The signer does not store a "
                        .concat(contractName)
                        .concat(" Collection object at the path ")
                        .concat(self.collectionData.storagePath.toString())
                        .concat("The signer must initialize their account with this collection first!"))
  • If you do need to use some sort of symbol to contain values, try to use parentheses. For example:
        let resolverRef = getAccount(contractAddress)
            .contracts.borrow<&{NonFungibleToken}>(name: contractName)
                ?? panic("Could not borrow NonFungibleToken reference to the contract. Make sure the provided contract name ("
                         .concat(contractName).concat(") and address (").concat(contractAddress.toString()).concat(") are correct!"))

These are all up for debate

We also will likely want to include pages in the docs sites for recommendations for error messages
We will also need to reach out to important partners to get them to update theirs as well

Repos to update:

  • flow-nft
  • flow-ft
  • bridged-usdc
  • flow-core-contracts
  • nft-storefront
  • nft-catalog
  • hybrid-custody
  • Rewards
  • EVM Bridge
  • contract-updater
  • tutorials
  • ft and nft guides
  • Flow Wallet Transactions
  • dapper repos
  • FIND
  • Flowty
  • Increment

What are you currently working on that this is blocking?

Users are confused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✋ Blocked
Development

No branches or pull requests

1 participant