Skip to content

Standardize error messages with interpolation and descriptive context#189

Open
joshuahannan wants to merge 2 commits intomasterfrom
fix/error-message-format
Open

Standardize error messages with interpolation and descriptive context#189
joshuahannan wants to merge 2 commits intomasterfrom
fix/error-message-format

Conversation

@joshuahannan
Copy link
Member

Summary

  • Replace all .concat() chains in error messages with Cadence string interpolation \()
  • Add ContractName.Resource.function: prefix to all contract-level panic messages
  • Embed relevant variable values (addresses, paths, types, balances) directly in messages to aid debugging
  • Fix vague/inaccurate messages (e.g. "transaction" → "script" in script files, "signer" → "recipient" where appropriate)

Addresses onflow/docs#795, following the pattern established in onflow/flow-core-contracts#582.

Files changed

Contracts (5): FungibleToken.cdc, FungibleTokenMetadataViews.cdc, FungibleTokenSwitchboard.cdc, TokenForwarding.cdc, PrivateReceiverForwarder.cdc

Transactions (20+): All transaction and script files under transactions/

Generated: lib/go/contracts/internal/assets/assets.go, lib/go/templates/internal/assets/assets.go (regenerated via make generate)

Test plan

  • make test — all Cadence and Go tests pass
  • make cigit diff --exit-code clean, all tests pass

🤖 Generated with Claude Code

…ripts

- Use string interpolation (\()) instead of .concat() chains throughout
- Add ContractName.Resource.function: prefix format to contract panics
- Embed relevant variable values (addresses, paths, types, balances) in messages
- Make messages more descriptive and actionable with context about root cause

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@joshuahannan joshuahannan requested a review from SupunS March 24, 2026 22:12
?? panic("TokenForwarding.Forwarder.deposit: Could not borrow a Receiver reference from the recipient capability. "
.concat("This is likely because the recipient account has removed their Vault or public capability. ")
.concat("The owner of this Forwarder should call changeRecipient to update it to a valid receiver."))
?? panic("TokenForwarding.Forwarder.deposit: Could not borrow a Receiver reference from the recipient capability. This is likely because the recipient account has removed their Vault or public capability. The owner of this Forwarder should call changeRecipient to update it to a valid receiver.")
Copy link
Member

@SupunS SupunS Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a personal preference: Having a backtick/single-quote to enclose names (type-names/function-names/etc.) might make it a little easier to distinguish them from the rest of the error message.
e.g:

"TokenForwarding.Forwarder.deposit: Could not borrow a `Receiver` reference from the recipient capability. This is likely because the recipient account has removed their `Vault` or public capability. The owner of this `Forwarder` should call `changeRecipient` to update it to a valid receiver."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants