Skip to content

Commit 92d249f

Browse files
committed
Update CLAUDE.md and README: fix stale filename, document error atoms
1 parent b6e14c7 commit 92d249f

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
88
TORQUE_BUILD=true mix deps.get # fetch deps + force local Rust build
99
TORQUE_BUILD=true mix compile # build (includes Rust NIF compilation)
1010
TORQUE_BUILD=true mix test # run all tests
11-
mix test test/torque_test.exs:42 # run single test by line number
11+
mix test test/pointer_test.exs:42 # run single test by line number
1212
mix compile --warnings-as-errors # build with strict warnings
1313
mix format # format Elixir code
1414
mix format --check-formatted # check Elixir formatting
@@ -67,4 +67,4 @@ Inputs larger than 10 KB are automatically dispatched to dirty CPU schedulers to
6767
- `native/torque_nif/src/decoder.rs` — parse, get, get_many, decode NIFs
6868
- `native/torque_nif/src/encoder.rs` — direct term-walking JSON encoder
6969
- `native/torque_nif/src/types.rs` — sonic_rs Value → Erlang term conversion
70-
- `native/torque_nif/src/atoms.rs` — cached atoms (ok, error, no_such_field, nil)
70+
- `native/torque_nif/src/atoms.rs` — cached atoms (ok, error, nil, no_such_field, nesting_too_deep, unsupported_type, non_finite_float, invalid_key, malformed_proplist, invalid_utf8)

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,29 @@ For objects with duplicate keys, the last value wins.
116116
| atom | string |
117117
| `{keyword_list}` | object |
118118

119+
## Errors
120+
121+
Functions return `{:error, reason}` tuples (or raise `ArgumentError` for bang/iodata variants). Possible `reason` atoms:
122+
123+
### Decode / Parse
124+
125+
| Atom | Returned by | Meaning |
126+
|------|-------------|---------|
127+
| `:nesting_too_deep` | `decode/1`, `parse/1`, `get/2,3` | Document exceeds 512 nesting levels |
128+
129+
`parse/1` and `decode/1` also return `{:error, binary}` with a message from sonic-rs for malformed JSON.
130+
131+
### Encode
132+
133+
| Atom | Returned by | Meaning |
134+
|------|-------------|---------|
135+
| `:unsupported_type` | `encode/1` | Term has no JSON representation (PID, reference, port, …) |
136+
| `:invalid_utf8` | `encode/1` | Binary string or map key is not valid UTF-8 |
137+
| `:invalid_key` | `encode/1` | Map key is not an atom or binary (e.g. integer key) |
138+
| `:malformed_proplist` | `encode/1` | `{proplist}` contains a non-`{key, value}` element |
139+
| `:non_finite_float` | `encode/1` | Float is infinity or NaN (unreachable from normal BEAM code) |
140+
| `:nesting_too_deep` | `encode/1` | Term exceeds 512 nesting levels |
141+
119142
## Benchmarks
120143

121144
Apple M2 Pro, OTP 28, Elixir 1.19:

0 commit comments

Comments
 (0)