Errors & Logs Best Practices
Balance observability with CU discipline: stable error codes for clients, gated logs for engineers, structured events for indexers.
Search across all documentation pages
Balance observability with CU discipline: stable error codes for clients, gated logs for engineers, structured events for indexers.
ProgramError - never panic on user-controlled input. Clean failure codes.msg! behind features in release builds. CU control.MYAPP:step). Ops efficiency.Errors fail; events observe success paths mainly.
Still gate logs and publish IDL.
Same syscall costs.
Off-chain map codes.
Index events not raw spam logs.
Logs affect landing on tight ix.
Error table frozen - plan codes.
Debug default.
Client decode standard.
Errors can leak hints - generic user text.
No PII in logs.
Fail on new panic paths.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026