Skip to content

sdk: Stable numeric error codes for i18n support#716

Open
cdecker wants to merge 2 commits into
mainfrom
2026w20-num-errors
Open

sdk: Stable numeric error codes for i18n support#716
cdecker wants to merge 2 commits into
mainfrom
2026w20-num-errors

Conversation

@cdecker
Copy link
Copy Markdown
Collaborator

@cdecker cdecker commented May 13, 2026

Summary

  • Replace gl-sdk tuple-style error variants with named-field variants carrying code: i32, message: String, and values: HashMap<String, String>
  • Each error has a stable numeric code (1000-1099 node identity, 1100-1199 credentials, 2000-2099 RPC, 3000-3099 validation, 9000-9099 generic) enabling host-language i18n lookup
  • The values map provides structured interpolation keys so callers can fill translated templates (e.g., "Node {node_id} already exists")
  • Constructor functions (Error::rpc(), Error::other(), etc.) keep call sites clean
  • Regenerated Python, Kotlin, Swift, and Ruby bindings — all expose .code, .message, .values on error subclasses

Test plan

  • cargo build -p gl-sdk compiles cleanly
  • Verified generated Python bindings have code, message, values attributes on all Error subclasses
  • Verified generated Kotlin bindings have val code: Int, val message: String, val values: Map<String, String>
  • Verified generated Swift bindings have code: Int32, message: String, values: [String: String]
  • Integration test with host-language error catching and i18n template interpolation

🤖 Generated with Claude Code

cdecker and others added 2 commits May 13, 2026 17:52
Replace tuple-style error variants with named-field variants carrying
code (i32), message (String), and values (HashMap<String, String>).
This allows host-language callers to look up translated error strings
by numeric code and interpolate structured values, rather than parsing
English messages.

Error code ranges: 1000-1099 node identity, 1100-1199 credentials,
2000-2099 RPC, 3000-3099 input validation, 9000-9099 generic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant