Nessuna descrizione

UserFacingErrorMessage.swift 849B

123456789101112131415161718192021222324
  1. import Foundation
  2. /// Maps backend and network errors to short, safe copy for the UI.
  3. enum UserFacingErrorMessage {
  4. static func jobSearchFailure(_ error: Error) -> String {
  5. if let urlError = error as? URLError {
  6. switch urlError.code {
  7. case .notConnectedToInternet,
  8. .networkConnectionLost,
  9. .timedOut,
  10. .cannotFindHost,
  11. .cannotConnectToHost,
  12. .dnsLookupFailed:
  13. return "We couldn't reach the server. Check your internet connection and try again."
  14. case .cancelled:
  15. return "The search was cancelled. Try again when you're ready."
  16. default:
  17. break
  18. }
  19. }
  20. return "Something went wrong while searching. Please try again in a moment."
  21. }
  22. }