Skip to content

fix(browser): BrowserDb errors carry their error code (#673) - #675

Merged
adityamukho merged 3 commits into
v3from
fix/673-browser-error-codes
Oct 21, 2026
Merged

adityamukho merged 3 commits into
v3from
fix/673-browser-error-codes

Conversation

@adityamukho

Copy link
Copy Markdown
Collaborator

Fixes #673 on v3. The backport to main (for v2.0.9) follows as a separate PR.

BrowserDb converted errors with JsValue::from_str(&e.to_string()), which formats an anyhow::Error without its code. So the browser API rejected with Unknown command: nosuchcommand where every other API says [PRS-001] Unknown command: nosuchcommand.

  • Every anyhow conversion in src/browser/mod.rs (14 sites) now uses the existing to_js_error (MinigrafError::from(e).to_string()). BrowserCursor::nextBatch already got a MinigrafError, so it keeps to_string(), which includes the code.
  • New #[wasm_bindgen_test] execute_errors_carry_their_code: a parse error, a query error and a transact error each reject with a string that starts with [XXX-NNN]. It fails without the fix (checked locally in headless Firefox: 33 passed, 1 failed) and passes with it (34 passed).
  • Not changed: host errors that have no code yet (no window object, IndexedDB not available, an import blob whose length isn't a multiple of the page size, "database is too large to export"). Giving them codes means new registry entries; that's for a separate issue if wanted.
  • CHANGELOG: an entry under Unreleased › Fixed.

Found by the minigraf-wasm consumer test (minigraf-wasm#7). Its browser contract will require the code once the pinned core has this fix.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PtCdzbJMSS1V8qEPaJ4jXz

BrowserDb rejected with the anyhow error's top-level message only
("Unknown command: nosuchcommand"), so the browser API was the one API
without structured codes. Every anyhow conversion now goes through
to_js_error (MinigrafError::from), so a rejection starts with its code, as
on every other API. A browser test checks a parse, query and transact error.

Found by the minigraf-wasm consumer test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PtCdzbJMSS1V8qEPaJ4jXz
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PtCdzbJMSS1V8qEPaJ4jXz
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 377ab2f into v3 Oct 21, 2026
24 of 25 checks passed
@adityamukho
adityamukho deleted the fix/673-browser-error-codes branch October 21, 2026 07:01
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