Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #25.
Problem
The wasm bindings rejected with a plain string (
JsValue::from_str(e.to_string())), so JS consumers had to substring-match Display text — e.g.String(err).startsWith("conflict for")— to tell a unique-conflict from anything else. Fragile, and it breaks silently if the message wording changes.Change
Every failed
Storemethod now rejects with a structured JSError:stitch_errbuilds ajs_sys::Error(message = the variant's Display) and attaches a stablekindplusentity/idfor the variants that carry them, viaReflect::set.error_partsmaps everystitch::Errorvariant to akind(conflict,ownership,notFound,timeout,connectionClosed,sessionInvalid,mqtt,mqdb,config,serde,io,notInitialized,alreadyInitialized,scopeNotActive,unknownEntity) — exhaustive, so a futureErrorvariant won't compile until it's mapped.self.inner.*call sites route throughstitch_err; the serde/parse and non-serializable-input paths (JSON.stringifythrowing on aBigInt/circular ref) carrykind: "invalidInput". No path rejects with a bare string.Consumers can now write
err.kind === "conflict"and delete theirisUniqueViolationheuristic.Breaking
Rejections change from strings to
Errorobjects, soString(err)is now"Error: conflict for …". Callers matching the string must switch toerr.kind/err.message. That makes it a minor bump —stitch-wasm 0.5.0(left as[Unreleased]here;stitch-syncis untouched — the mapping lives entirely in the wasm crate).Verification
wasm32check + clippy clean, incl. two#[wasm_bindgen_test]s asserting the mapping (conflict → kind/entity/id/message; timeout → kind only; generic →invalidInput). Browser tests execute in CI.BigInt/circular ref) rejected without akindviaJSON.stringify's raw throw — now fixed by routing it throughinvalidInput. Re-verified clean.