25 - reworked client lib to use Result-Pattern instead of exceptions#69
Conversation
…sult-pattern-to-java-client-code
ReviewOverviewReplaces checked exceptions with a Rust-style Key pieces:
Verified
Potential issue
Minor
Overall this is a coherent, well-verified rework with good use of Java's sealed interfaces to keep each operation's error type exhaustive-switch-friendly. The one edge case above is the only thing I'd want addressed (or explicitly accepted as a known limitation) before merge. |
|
Follow-up: the unused-error edge case I flagged is fixed in 7d56ffe. `error.ts` now builds the `implements` list as an array seeded with `'RSDError'` via `combinations.unshift('RSDError')` before joining, so it always renders `implements RSDError` (plus any `E*` combinations) instead of producing a dangling trailing comma when an error isn't referenced by any operation. Re-verified `tsc --noEmit` and a clean `mvn compile` on `java-test/java-client` — both pass. No remaining concerns from my side. |
|
Re-checked after 1ad1edd ("make rsderror and sealed interface"): making `RSDError` itself a sealed interface with an explicit `permits` list is a nice tightening — confirmed it compiles and the permits set lines up with the set of direct implementors (every error record always `implements RSDError` per the earlier fix, plus `$GenericError`). However, the same class of bug as before still exists, just relocated — in `service-errors.ts`, the `$GenericError` record is generated as: ```ts If `errorNames` (the computed service-error combinations) is empty — i.e. a model with no `error` declarations at all, or one where no operation has a `throws` clause — this renders as `implements RSDError, {` (trailing comma, nothing after it), which won't compile. I verified this by evaluating the same ternary standalone with an empty array. None of the bundled `.rsd` test specs hit this (they all declare errors and throws), so it won't surface in CI as-is, but it's the identical root cause as the issue fixed in 7d56ffe, just not yet applied here. Same fix shape would work: build the implements list as an array seeded with `'RSDError'` and conditionally push the combination names, then `.join(', ')`. |
|
Re-checked after 8efca69: the `$GenericError` trailing-comma issue is fixed correctly — `implements RSDError${errorNames.length > 0 ? ', ' + ... : ''}` now renders `implements RSDError` alone when there are no combinations, or `implements RSDError, E1, E2` when there are, with no dangling comma either way. Verified `tsc --noEmit` and `mvn clean compile` on `java-test/java-client` both pass. No remaining concerns — LGTM. |
No description provided.