Skip to content

Commit 43f0b3e

Browse files
committed
Fix error descriptions Embedded Swift compatibility
The BridgeJS generator emits `JSError(message: String(describing: error))` for throwing `@JS` exports, but `String.init(describing:)` is unavailable in Embedded Swift, so embedded Wasm builds of any package with a throwing export fail. The caught error is statically a `JSException` with a stored `description`, so the generated glue now uses `error.description` for identical output. Snapshots regenerated.
1 parent 9706c4c commit 43f0b3e

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ public class ExportSwift {
453453
_swift_js_throw(Int32(bitPattern: $0.id))
454454
}
455455
} else {
456-
let jsError = JSError(message: String(describing: error))
456+
let jsError = JSError(message: error.description)
457457
withExtendedLifetime(jsError.jsObject) {
458458
_swift_js_throw(Int32(bitPattern: $0.id))
459459
}

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumNamespace.Global.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public func _bjs_Services_Graph_GraphOperations_static_validate(_ graphId: Int32
117117
_swift_js_throw(Int32(bitPattern: $0.id))
118118
}
119119
} else {
120-
let jsError = JSError(message: String(describing: error))
120+
let jsError = JSError(message: error.description)
121121
withExtendedLifetime(jsError.jsObject) {
122122
_swift_js_throw(Int32(bitPattern: $0.id))
123123
}

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumNamespace.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public func _bjs_Services_Graph_GraphOperations_static_validate(_ graphId: Int32
117117
_swift_js_throw(Int32(bitPattern: $0.id))
118118
}
119119
} else {
120-
let jsError = JSError(message: String(describing: error))
120+
let jsError = JSError(message: error.description)
121121
withExtendedLifetime(jsError.jsObject) {
122122
_swift_js_throw(Int32(bitPattern: $0.id))
123123
}

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ImportedTypeInExportedInterface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public func _bjs_makeFoo() -> Int32 {
5959
_swift_js_throw(Int32(bitPattern: $0.id))
6060
}
6161
} else {
62-
let jsError = JSError(message: String(describing: error))
62+
let jsError = JSError(message: error.description)
6363
withExtendedLifetime(jsError.jsObject) {
6464
_swift_js_throw(Int32(bitPattern: $0.id))
6565
}

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/Throws.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public func _bjs_throwsSomething() -> Void {
1010
_swift_js_throw(Int32(bitPattern: $0.id))
1111
}
1212
} else {
13-
let jsError = JSError(message: String(describing: error))
13+
let jsError = JSError(message: error.description)
1414
withExtendedLifetime(jsError.jsObject) {
1515
_swift_js_throw(Int32(bitPattern: $0.id))
1616
}

0 commit comments

Comments
 (0)