Skip to content

Standardize error messages: add prefixes and use string interpolation#268

Merged
joshuahannan merged 3 commits intomasterfrom
standardize-error-messages
Mar 25, 2026
Merged

Standardize error messages: add prefixes and use string interpolation#268
joshuahannan merged 3 commits intomasterfrom
standardize-error-messages

Conversation

@joshuahannan
Copy link
Copy Markdown
Contributor

Summary

Resolves onflow/docs#795

  • Add ContractName.Resource.function: prefixes to all contract-level panics so errors are immediately traceable to their source
  • Add transaction filename prefixes (e.g. mint_nft:, transfer_nft:) to all transaction panics
  • Replace all .concat() chaining with Cadence \() string interpolation throughout
  • Embed variable values directly in messages (IDs, addresses, paths, types) so users immediately see what went wrong
  • Remove a redundant dead-code check in setup_account_to_receive_royalty.cdc (second if was unreachable after the first)

Files changed

Contracts:

  • contracts/MetadataViews.cdcRarity.init
  • contracts/ExampleNFT.cdcCollection.withdraw, createEmptyCollection
  • contracts/utility/NFTForwarding.cdcgetSupportedNFTTypes, deposit post-condition, deposit panic

Transactions:

  • transactions/mint_nft.cdc
  • transactions/transfer_nft.cdc
  • transactions/generic_transfer_with_address_and_type.cdc
  • transactions/generic_transfer_with_paths.cdc
  • transactions/generic_destroy_nft.cdc
  • transactions/destroy_nft.cdc
  • transactions/setup_account.cdc
  • transactions/setup_account_from_nft_reference.cdc
  • transactions/setup_account_to_receive_royalty.cdc
  • transactions/unlink_collection.cdc

Tests:

  • tests/test_helpers.cdc

Test plan

  • All Go tests pass (make test)
  • All Cadence tests pass (flow test)
  • Go assets regenerated (make generate)

🤖 Generated with Claude Code

joshuahannan and others added 2 commits March 19, 2026 12:29
- Add ContractName.Resource.function: prefixes to all contract panics
- Add transaction filename prefixes to all transaction panics
- Replace all .concat() chaining with Cadence \() string interpolation
- Embed relevant variable values (IDs, addresses, paths, types) directly
- Remove redundant dead-code check in setup_account_to_receive_royalty.cdc
- Resolves onflow/docs#795

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Also pulls in upgrades to cadence, flow-go, flow-go-sdk, atree,
and various other transitive dependencies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@joshuahannan joshuahannan merged commit 8875d2f into master Mar 25, 2026
2 checks passed
@joshuahannan joshuahannan deleted the standardize-error-messages branch March 25, 2026 20:00
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.

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

2 participants