Skip to content

Commit

Permalink
add function to allow detection of timeout errors
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Mar 25, 2024
1 parent 70ef707 commit 906cfc8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/KukaiCoreSwift/Services/ErrorHandlingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@ public struct KukaiError: CustomStringConvertible, Error {
return "HTTP Status \(statusCode) \nUnable to communicate with: \(url.absoluteStringByTrimmingQuery() ?? url.absoluteString)"
}
}



// MARK: - Central callback parsers

/**
Allow the delegate of the error callback the ability to decide what errors to log or not by detecting the high level type of error being generated
*/
public func isTimeout(_ kukaiError: KukaiError) -> Bool {
return kukaiError.underlyingError?.domain == "NSURLErrorDomain" && kukaiError.underlyingError?.code == -1001
}
}


Expand Down

0 comments on commit 906cfc8

Please sign in to comment.