-
-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathAsyncThrows.swift
More file actions
33 lines (32 loc) · 978 Bytes
/
Copy pathAsyncThrows.swift
File metadata and controls
33 lines (32 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
@_expose(wasm, "bjs_asyncThrowsVoid")
@_cdecl("bjs_asyncThrowsVoid")
public func _bjs_asyncThrowsVoid() -> Int32 {
#if arch(wasm32)
let ret = JSPromise.async { () async throws(JSException) in
do {
try await asyncThrowsVoid()
} catch let error {
throw error.bridgeJSLowerThrowAsync()
}
}.jsObject
return ret.bridgeJSLowerReturn()
#else
fatalError("Only available on WebAssembly")
#endif
}
@_expose(wasm, "bjs_asyncThrowsWithResult")
@_cdecl("bjs_asyncThrowsWithResult")
public func _bjs_asyncThrowsWithResult() -> Int32 {
#if arch(wasm32)
let ret = JSPromise.async { () async throws(JSException) -> JSValue in
do {
return try await asyncThrowsWithResult().jsValue
} catch let error {
throw error.bridgeJSLowerThrowAsync()
}
}.jsObject
return ret.bridgeJSLowerReturn()
#else
fatalError("Only available on WebAssembly")
#endif
}