diff --git a/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Handlers/DeviceInfoHandler.swift b/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Handlers/DeviceInfoHandler.swift index 7bd5cc8f40..d91fbf5e92 100644 --- a/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Handlers/DeviceInfoHandler.swift +++ b/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Handlers/DeviceInfoHandler.swift @@ -17,7 +17,7 @@ struct DeviceInfoHandler: HTTPHandler { let springboardApp = XCUIApplication(bundleIdentifier: springboardBundleId) let screenSize = springboardApp.frame.size - let (width, height) = ScreenSizeHelper.actualScreenSize() + let (width, height) = try ScreenSizeHelper.actualScreenSize() let deviceInfo = DeviceInfoResponse( widthPoints: Int(width), heightPoints: Int(height), diff --git a/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Helpers/ScreenSizeHelper.swift b/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Helpers/ScreenSizeHelper.swift index 569acfc48d..bd8b9116f9 100644 --- a/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Helpers/ScreenSizeHelper.swift +++ b/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Helpers/ScreenSizeHelper.swift @@ -9,15 +9,15 @@ struct ScreenSizeHelper { } /// Takes device orientation into account. - static func actualScreenSize() -> (Float, Float) { + static func actualScreenSize() throws -> (Float, Float) { let orientation = XCUIDevice.shared.orientation let (width, height) = physicalScreenSize() let (actualWidth, actualHeight) = switch (orientation) { case .portrait, .portraitUpsideDown: (width, height) case .landscapeLeft, .landscapeRight: (height, width) - case .faceDown, .faceUp, .unknown: fatalError("Unsupported orientation: \(orientation)") - @unknown default: fatalError("Unsupported orientation: \(orientation)") + case .faceDown, .faceUp, .unknown: throw AppError(message: "Unsupported orientation: \(orientation)") + @unknown default: throw AppError(message: "Unsupported orientation: \(orientation)") } return (actualWidth, actualHeight)