Skip to content

Commit

Permalink
Improvement of the error messages #5
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasrichardrichter committed Jan 30, 2022
1 parent 2763885 commit 91fd2d4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Sources/CampusDualKit/ScheduleService/ScheduleServiceError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,45 @@ public enum ScheduleServiceError: Error {
case network(Error?)
case other(Error?)
}

extension ScheduleServiceError: LocalizedError {
public var errorDescription: String? {
switch self {
case .invalidURL:
switch Locale.current.languageCode {
case "de":
return "Es ist ein interner Fehler aufgetreten."
default:
return "An internal error has occurred."
}
case .wrongCredentials:
switch Locale.current.languageCode {
case "de":
return "Die Anmeldedaten sind nicht korrekt."
default:
return "The login credentials are not valid."
}
case .decoding(let error):
switch Locale.current.languageCode {
case "de":
return "Es ist ein Fehler bei der Verarbeitung der Daten aufgetreten. Mehr Informationen: \(error?.localizedDescription)"
default:
return "An error occurred while processing the data. More information: \(error?.localizedDescription)"
}
case .network(let error):
switch Locale.current.languageCode {
case "de":
return "Es ist ein Netzwerkfehler aufgetreten. Mehr Informationen: \(error?.localizedDescription)"
default:
return "A network error occurred. More information: \(error?.localizedDescription)"
}
case .other(let error):
switch Locale.current.languageCode {
case "de":
return "Ein unbekannter Fehler ist aufgetreten. Mehr Informationen: \(error?.localizedDescription)"
default:
return "An unknown error has occurred. More information: \(error?.localizedDescription)"
}
}
}
}

0 comments on commit 91fd2d4

Please sign in to comment.