Skip to content

Commit

Permalink
don't throw fatalError, throw instead
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Sep 9, 2024
1 parent f92b767 commit 806c533
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 806c533

Please sign in to comment.