Skip to content

Migrate to the split error-handler API (zenoh-flat-jni #45)#495

Merged
milyin merged 2 commits into
zenoh-flat-transitionfrom
split-error-handler
Jul 21, 2026
Merged

Migrate to the split error-handler API (zenoh-flat-jni #45)#495
milyin merged 2 commits into
zenoh-flat-transitionfrom
split-error-handler

Conversation

@milyin

@milyin milyin commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What

Migrates the SDK to zenoh-flat-jni's split error-handler API (prebindgen #45, zenoh-flat-jni PR).

The generated flat wrappers now split the error callback into two channels: the binding JniErrorHandler.run(je) (unchanged) and the typed domain ErrorHandler.run(message) (je removed, called only on a domain Err). A fallible wrapper takes both — onBindingError then onError.

Changes

exceptions/JNIErrorHandlers.kt:

  • throwZError → the 1-arg domain handler ErrorHandler { message -> throw ZError(message) }.
  • throwZError0 (the binding JniErrorHandler) is unchanged — it now doubles as the onBindingError of a fallible call.

Call sites: every fallible flat call gains throwZError0 before its throwZError42 sites across Config/Session/KeyExpr/Liveliness/Publisher/Querier/Query/Scout (+ one jvmTest), matching the wrapper's (…, onBindingError, onError) order. Infallible calls (bare throwZError0) and the binding-only Encoding.newFromId { je -> … } lambda are untouched.

Validation

Builds against the local composite zenoh-flat-jni (its split-error-handler branch); 120 jvmTest tests pass, including the domain-error paths (configFailsWithIllFormatedYAMLTest, insertIllFormattedJson5ShouldFailTest) that prove a zenoh error still surfaces as ZError.

Depends on the zenoh-flat-jni split-error-handler PR merging first.

🤖 Generated with Claude Code

prebindgen split the generated JNI error callback into two channels: the
binding `JniErrorHandler.run(je)` (unchanged) and the typed domain
`ErrorHandler.run(message)` (`je` removed, called only on a domain `Err`).
A fallible flat wrapper now takes both — `onBindingError` then `onError`.

`JNIErrorHandlers.kt`:
- `throwZError` becomes the 1-arg domain handler
  (`ErrorHandler { message -> throw ZError(message) }`).
- `throwZError0` (the binding `JniErrorHandler`) is unchanged — it now doubles
  as the `onBindingError` of a fallible call.

Call sites: every fallible flat call gains `throwZError0` before its
`throwZError` (42 sites across Config/Session/KeyExpr/Liveliness/Publisher/
Querier/Query/Scout + one jvmTest), matching the wrapper's
`(…, onBindingError, onError)` order. Infallible calls (`throwZError0`) and
the binding-only `Encoding.newFromId { je -> … }` lambda are untouched.

Builds against the local composite zenoh-flat-jni (split-error-handler);
120 jvmTest tests pass, including the domain-error paths
(`configFailsWithIllFormatedYAMLTest`, `insertIllFormattedJson5ShouldFailTest`).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@milyin
milyin changed the base branch from shared-parameters to zenoh-flat-transition July 21, 2026 11:10
@milyin
milyin force-pushed the split-error-handler branch 2 times, most recently from 7f41c39 to f695913 Compare July 21, 2026 11:19
The split error-handler regeneration (zenoh-flat-jni #10) plus the merged
Kotlin ownership-marker fix (zenoh-flat-jni #11, 249fe9e on shared-parameters).
CI pinned the pre-split 757cc6a, whose single-channel
`ErrorHandler.run(je, message)` wrappers are incompatible with this branch's
two-caller call sites; #11's marker is also required for the composite
`cargo build` to regenerate at all (write_kotlin refuses a non-empty output
root without it). Point CI at the merged commit so the composite build both
matches the source and regenerates.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@milyin
milyin force-pushed the split-error-handler branch from f695913 to 45d8787 Compare July 21, 2026 11:30
@milyin
milyin merged commit 646a05f into zenoh-flat-transition Jul 21, 2026
13 checks passed
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