| 123456789101112131415161718192021222324 |
- import Foundation
- /// Maps backend and network errors to short, safe copy for the UI.
- enum UserFacingErrorMessage {
- static func jobSearchFailure(_ error: Error) -> String {
- if let urlError = error as? URLError {
- switch urlError.code {
- case .notConnectedToInternet,
- .networkConnectionLost,
- .timedOut,
- .cannotFindHost,
- .cannotConnectToHost,
- .dnsLookupFailed:
- return L("We couldn't reach the server. Check your internet connection and try again.")
- case .cancelled:
- return L("The search was cancelled. Try again when you're ready.")
- default:
- break
- }
- }
- return L("Something went wrong while searching. Please try again in a moment.")
- }
- }
|