Standardize error messages with interpolation and descriptive context#189
Open
joshuahannan wants to merge 2 commits intomasterfrom
Open
Standardize error messages with interpolation and descriptive context#189joshuahannan wants to merge 2 commits intomasterfrom
joshuahannan wants to merge 2 commits intomasterfrom
Conversation
…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>
SupunS
approved these changes
Mar 25, 2026
| ?? 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.") |
Member
There was a problem hiding this comment.
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."
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.concat()chains in error messages with Cadence string interpolation\()ContractName.Resource.function:prefix to all contract-levelpanicmessagesAddresses 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.cdcTransactions (20+): All transaction and script files under
transactions/Generated:
lib/go/contracts/internal/assets/assets.go,lib/go/templates/internal/assets/assets.go(regenerated viamake generate)Test plan
make test— all Cadence and Go tests passmake ci—git diff --exit-codeclean, all tests pass🤖 Generated with Claude Code