|
1 | 1 | import { HostProcessPlatform } from "@t3tools/shared/hostProcess"; |
| 2 | +import type * as Cause from "effect/Cause"; |
2 | 3 | import * as Context from "effect/Context"; |
3 | 4 | import * as Effect from "effect/Effect"; |
| 5 | +import * as Exit from "effect/Exit"; |
4 | 6 | import * as Layer from "effect/Layer"; |
5 | 7 | import * as Option from "effect/Option"; |
6 | 8 | import * as Ref from "effect/Ref"; |
@@ -257,18 +259,27 @@ export const make = Effect.gen(function* () { |
257 | 259 | } |
258 | 260 | }), |
259 | 261 | destroyAll: Effect.gen(function* () { |
| 262 | + let firstFailure: Cause.Cause<never> | undefined; |
260 | 263 | for (const window of yield* listWindows) { |
261 | | - yield* Effect.try({ |
262 | | - try: () => window.destroy(), |
263 | | - catch: (cause) => |
264 | | - new ElectronWindowOperationError({ |
265 | | - operation: "destroy-window", |
266 | | - platform, |
267 | | - windowId: window.id, |
268 | | - channel: null, |
269 | | - cause, |
270 | | - }), |
271 | | - }).pipe(Effect.orDie); |
| 264 | + const exit = yield* Effect.exit( |
| 265 | + Effect.try({ |
| 266 | + try: () => window.destroy(), |
| 267 | + catch: (cause) => |
| 268 | + new ElectronWindowOperationError({ |
| 269 | + operation: "destroy-window", |
| 270 | + platform, |
| 271 | + windowId: window.id, |
| 272 | + channel: null, |
| 273 | + cause, |
| 274 | + }), |
| 275 | + }).pipe(Effect.orDie), |
| 276 | + ); |
| 277 | + if (Exit.isFailure(exit)) { |
| 278 | + firstFailure ??= exit.cause; |
| 279 | + } |
| 280 | + } |
| 281 | + if (firstFailure !== undefined) { |
| 282 | + return yield* Effect.failCause(firstFailure); |
272 | 283 | } |
273 | 284 | }), |
274 | 285 | syncAllAppearance: Effect.fn("desktop.electron.window.syncAllAppearance")(function* <E, R>( |
|
0 commit comments