ErrorHandlingService
public class ErrorHandlingService
A class used to process errors into more readable format, and optionally notifiy a global error handler of every error occuring
-
Shared instance so that it can hold onto an event closure
Declaration
Swift
public static let shared: ErrorHandlingService
-
Called everytime an error is parsed. Extremely useful to track / log errors globally, in order to run logic or record to external service
Declaration
Swift
public var errorEventClosure: ((KukaiError) -> Void)?
-
Convert an
OperationResponseInternalResultError
into aKukaiError
and optionally log it to the central loggerDeclaration
Swift
public static func fromOperationError(_ opError: OperationResponseInternalResultError, requestURL: URL?, andLog: Bool = true) -> KukaiError
-
Declaration
Swift
public static func knownRPCErrorString(rpcStringWithoutLeadingProtocol: String?, with: FailWith?) -> String?
-
Search an
OperationResponse
to see does it contain any errors, if so return the last one as aKukaiError
and optionally log it to the central loggerDeclaration
Swift
public static func searchOperationResponseForErrors(_ opResponse: OperationResponse, requestURL: URL?, andLog: Bool = true) -> KukaiError?
-
Search an
[OperationResponse]
to see does it contain any errors, if so return the last one as aKukaiError
and optionally log it to the central loggerDeclaration
Swift
public static func searchOperationResponseForErrors(_ opResponse: [OperationResponse], requestURL: URL?, andLog: Bool = true) -> KukaiError?
-
Take in network response data and see does it contain an error, if so return create a
KukaiError
from it and optionally log it to the central loggerDeclaration
Swift
public static func searchForSystemError(data: Data?, response: URLResponse?, networkError: Error?, requestURL: URL, requestData: Data?, andLog: Bool = true) -> KukaiError?