Skip to content

Commit dd75f60

Browse files
committed
don't silently fail if openWindow(id:) is called with an invalid ID
1 parent 4116bff commit dd75f60

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Sources/SwiftCrossUI/Environment/Actions/OpenWindowAction.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
public struct OpenWindowAction {
44
/// Opens the window with the specified ID.
55
public func callAsFunction(id: String) {
6-
windowOpenFunctionsByID[id]?()
6+
guard let openWindow = windowOpenFunctionsByID[id] else {
7+
// FIXME: replace with logger.warning once that PR's merged
8+
print(
9+
"""
10+
warning: openWindow(id:) called with an ID that does not have \
11+
an associated window: '\(id)'
12+
"""
13+
)
14+
return
15+
}
16+
openWindow()
717
}
818
}

0 commit comments

Comments
 (0)