From 806c5338609b6d31178d7e0c1cfc52dabafe2021 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Fri, 30 Aug 2024 13:50:09 +0200 Subject: [PATCH] don't throw `fatalError`, `throw` instead --- .../main/kotlin/xcuitest/installer/LocalXCTestInstaller.kt | 2 -- .../Routes/Handlers/DeviceInfoHandler.swift | 2 +- .../Routes/Helpers/ScreenSizeHelper.swift | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/maestro-ios-driver/src/main/kotlin/xcuitest/installer/LocalXCTestInstaller.kt b/maestro-ios-driver/src/main/kotlin/xcuitest/installer/LocalXCTestInstaller.kt index c535bacbcf..15888efdd2 100644 --- a/maestro-ios-driver/src/main/kotlin/xcuitest/installer/LocalXCTestInstaller.kt +++ b/maestro-ios-driver/src/main/kotlin/xcuitest/installer/LocalXCTestInstaller.kt @@ -2,11 +2,9 @@ package xcuitest.installer import logger.Logger import maestro.utils.MaestroTimer -import maestro.utils.SocketUtils import okhttp3.HttpUrl import okhttp3.OkHttpClient import okhttp3.Request -import okhttp3.Response import okio.buffer import okio.sink import okio.source 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)