Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Error Model

TON SDK errors should preserve the subsystem boundary where the error occurred. This is required for retry policy, user diagnostics, and safe proof handling.

Error Families

FamilyExamplesRetry behavior
TL serializationunknown constructor, invalid bytes padding, EOFusually no
ADNL transportIO error, integrity error, EOF, invalid handshakeretry another peer
LiteAPI serverliteServer.errorusually no
TVM datamalformed BoC, cell overflow, invalid addressno until input changes
Contract executionnon-zero get-method exit codeno, semantic result
Proof verificationinvalid signature, invalid Merkle proofno; mark peer/data untrusted
Balancer stateno alive peers, no archival peerretry after reconnect

Design Rules

  • Do not map all errors to anyhow::Error in public APIs.
  • Preserve server error code and message.
  • Preserve ADNL error variants for balancer retry decisions.
  • Preserve TVM decode context when decoding cells, BoC, stack, or TLB data.
  • Contract execution errors must include exit code and raw result bytes if available.

Current Gaps

  • LiteError::ServerError does not include a user-friendly display of code and message.
  • Some TVM APIs return anyhow::Error.
  • Balancer retry policy only partially distinguishes transport and semantic errors.
  • Proof verification error types do not exist yet.