|
1 | 1 | import JavaScriptKit
|
| 2 | +import _Concurrency |
2 | 3 | import _CJavaScriptEventLoop
|
3 | 4 | import _CJavaScriptKit
|
4 | 5 |
|
@@ -259,38 +260,38 @@ extension JavaScriptEventLoop {
|
259 | 260 | extension JSPromise {
|
260 | 261 | /// Wait for the promise to complete, returning (or throwing) its result.
|
261 | 262 | public var value: JSValue {
|
262 |
| - get async throws { |
263 |
| - try await withUnsafeThrowingContinuation { [self] continuation in |
| 263 | + get async throws(JSException) { |
| 264 | + try await withUnsafeContinuation { [self] continuation in |
264 | 265 | self.then(
|
265 | 266 | success: {
|
266 |
| - continuation.resume(returning: $0) |
| 267 | + continuation.resume(returning: Swift.Result<JSValue, JSException>.success($0)) |
267 | 268 | return JSValue.undefined
|
268 | 269 | },
|
269 | 270 | failure: {
|
270 |
| - continuation.resume(throwing: JSException($0)) |
| 271 | + continuation.resume(returning: Swift.Result<JSValue, JSException>.failure(.init($0))) |
271 | 272 | return JSValue.undefined
|
272 | 273 | }
|
273 | 274 | )
|
274 |
| - } |
| 275 | + }.get() |
275 | 276 | }
|
276 | 277 | }
|
277 | 278 |
|
278 | 279 | /// Wait for the promise to complete, returning its result or exception as a Result.
|
279 | 280 | ///
|
280 | 281 | /// - Note: Calling this function does not switch from the caller's isolation domain.
|
281 |
| - public func value(isolation: isolated (any Actor)? = #isolation) async throws -> JSValue { |
282 |
| - try await withUnsafeThrowingContinuation(isolation: isolation) { [self] continuation in |
| 282 | + public func value(isolation: isolated (any Actor)? = #isolation) async throws(JSException) -> JSValue { |
| 283 | + try await withUnsafeContinuation(isolation: isolation) { [self] continuation in |
283 | 284 | self.then(
|
284 | 285 | success: {
|
285 |
| - continuation.resume(returning: $0) |
| 286 | + continuation.resume(returning: Swift.Result<JSValue, JSException>.success($0)) |
286 | 287 | return JSValue.undefined
|
287 | 288 | },
|
288 | 289 | failure: {
|
289 |
| - continuation.resume(throwing: JSException($0)) |
| 290 | + continuation.resume(returning: Swift.Result<JSValue, JSException>.failure(.init($0))) |
290 | 291 | return JSValue.undefined
|
291 | 292 | }
|
292 | 293 | )
|
293 |
| - } |
| 294 | + }.get() |
294 | 295 | }
|
295 | 296 |
|
296 | 297 | /// Wait for the promise to complete, returning its result or exception as a Result.
|
|
0 commit comments