field_ios

In-the-field app for Radroots on iOS
git clone https://radroots.dev/git/field_ios.git
Log | Files | Refs | README | LICENSE

TeraRuntimeFailureMapping.swift (1779B)


      1 import Foundation
      2 
      3 extension TeraRuntimeClient {
      4   static func deadlineFailure(
      5     identity: TeraRuntimeOperationIdentity
      6   ) -> TeraRuntimeFailure {
      7     .local(
      8       operation: identity.rawValue,
      9       code: "ios.runtime.deadline_exceeded",
     10       safeMessage: "The Tera runtime operation did not finish in time."
     11     )
     12   }
     13 
     14   static func cancellationFailure(
     15     identity: TeraRuntimeOperationIdentity
     16   ) -> TeraRuntimeFailure {
     17     .local(
     18       operation: identity.rawValue,
     19       code: "ios.runtime.cancelled",
     20       safeMessage: "The Tera runtime operation was cancelled."
     21     )
     22   }
     23 
     24   static func failure(from error: Error, operation: String) -> TeraRuntimeFailure {
     25     if let failure = error as? TeraRuntimeFailure {
     26       return failure
     27     }
     28     if error is CancellationError {
     29       return .local(
     30         operation: operation,
     31         code: "ios.runtime.cancelled",
     32         safeMessage: "The Tera runtime operation was cancelled."
     33       )
     34     }
     35     if case let TeraRuntimeClientError.startup(failure) = error {
     36       return failure
     37     }
     38     if case let TeraRuntimeClientError.subscription(failure) = error {
     39       return failure
     40     }
     41     if case let TeraRuntimeClientError.status(failure) = error {
     42       return failure
     43     }
     44     if case let TeraRuntimeClientError.today(failure) = error {
     45       return failure
     46     }
     47     if case let TeraRuntimeClientError.add(failure) = error {
     48       return failure
     49     }
     50     if case let TeraRuntimeClientError.support(failure) = error {
     51       return failure
     52     }
     53     if case let TeraRuntimeClientError.shutdown(failure) = error {
     54       return failure
     55     }
     56     return .local(
     57       operation: operation,
     58       code: "ios.runtime.unexpected",
     59       safeMessage: "The Tera runtime could not complete the operation."
     60     )
     61   }
     62 }