Commit d378e67
fix(demo): propagate CancellationException through outer catches
The previous commit added `catch (e: CancellationException) { throw e }`
inside `postNotification`, but the re-thrown cancellation was caught
again one frame up by `sendNotification` / `sendCustomNotification`'s
outer `catch (e: Exception)`, silently undoing the fix. The same
anti-pattern lived in `OneSignalService.fetchUser` (wrapping
`withContext(Dispatchers.IO)` + `connection.responseCode`) and
`MainViewModel.fetchUserDataFromApi` (wrapping `repository.fetchUser`,
the inner `withContext(Dispatchers.Main)`, and `delay(100)`).
Add a `CancellationException` re-throw clause ahead of each generic
`Exception` catch so structured-concurrency cancellation propagates all
the way up to the cancelled scope instead of being swallowed as a
misleading I/O error.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent a813284 commit d378e67
3 files changed
Lines changed: 9 additions & 1 deletion
File tree
- examples/demo/app/src/main/java/com/onesignal/example
- data/network
- ui/main
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
| 115 | + | |
| 116 | + | |
113 | 117 | | |
114 | 118 | | |
115 | 119 | | |
| |||
256 | 260 | | |
257 | 261 | | |
258 | 262 | | |
| 263 | + | |
| 264 | + | |
259 | 265 | | |
260 | 266 | | |
261 | 267 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
| 238 | + | |
| 239 | + | |
237 | 240 | | |
238 | 241 | | |
239 | 242 | | |
| |||
0 commit comments