|
|
|
|
@ -20,14 +20,33 @@ public class ErrorUtils { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public enum ServiceError: Error { |
|
|
|
|
public enum ServiceError: Error, LocalizedError { |
|
|
|
|
case urlCreationError(url: String) |
|
|
|
|
case cantConvertToUUID(id: String) |
|
|
|
|
case missingUserName |
|
|
|
|
case missingUserId |
|
|
|
|
case responseError(response: String) |
|
|
|
|
|
|
|
|
|
public var errorDescription: String? { |
|
|
|
|
switch self { |
|
|
|
|
case .urlCreationError(let url): |
|
|
|
|
return "Can't create URL from \(url)" |
|
|
|
|
case .cantConvertToUUID(let id): |
|
|
|
|
return "Cant convert \(id) to UUID" |
|
|
|
|
case .missingUserName: |
|
|
|
|
return "There is no userName defined in the Settings" |
|
|
|
|
case .responseError(let response): |
|
|
|
|
return "The server returned an error: \(response)" |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public enum UUIDError: Error { |
|
|
|
|
public enum UUIDError: Error, LocalizedError { |
|
|
|
|
case cantConvertString(string: String) |
|
|
|
|
|
|
|
|
|
public var errorDescription: String? { |
|
|
|
|
switch self { |
|
|
|
|
case .cantConvertString(let string): |
|
|
|
|
return "cant convert string to UUID: \(string)" |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|