Commit 62cbc5e
authored
Fix exception handling in Kotlin request executor (#1025)
Added comprehensive exception handling to prevent UnexpectedUniFFICallbackError
crashes when network exceptions occur. The executor now properly catches and
maps all exceptions to appropriate Rust error types.
Without proper exception handling, uncaught exceptions from OkHttp would crash
the UniFFI callback layer instead of being returned as proper errors to Rust.
This was causing API discovery and other network operations to fail with
UnexpectedUniFFICallbackError instead of meaningful error messages.
Changes:
- Add ConnectException handler to map connection failures to HttpError
- Add catch-all Exception handler to map unexpected errors to GenericError
- Add testLocalSite integration test to verify localhost API discovery works1 parent 3d2dafd commit 62cbc5e
File tree
2 files changed
+25
-1
lines changed- native/kotlin/api/kotlin/src
- integrationTest/kotlin
- main/kotlin/rs/wordpress/api/kotlin
2 files changed
+25
-1
lines changedLines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
| |||
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
133 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
| |||
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
165 | 180 | | |
166 | 181 | | |
167 | 182 | | |
| |||
0 commit comments