File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ struct SWError {
1111 case networkRequestFailed = - 6001
1212 case jsonSerializationFailed = - 6002
1313 case jsonParsingFailed = - 6003
14+ case unableToFindLocation = - 6004
1415 }
1516
1617 let errorCode : Code
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import CoreLocation
88
99protocol LocationServiceDelegate {
1010 func locationDidUpdate( _ service: LocationService , location: CLLocation )
11+ func locationDidFail( withError error: SWError )
1112}
1213
1314class LocationService : NSObject {
@@ -38,6 +39,8 @@ extension LocationService : CLLocationManagerDelegate {
3839 }
3940
4041 func locationManager( _ manager: CLLocationManager , didFailWithError error: Error ) {
42+ let swError = SWError ( errorCode: . unableToFindLocation)
43+ delegate? . locationDidFail ( withError: swError)
4144 print ( " Error finding location: \( error. localizedDescription) " )
4245 }
4346}
Original file line number Diff line number Diff line change @@ -71,8 +71,10 @@ class WeatherViewModel {
7171 errorMessage. value = " We're having trouble processing weather data. "
7272 case . jsonParsingFailed:
7373 errorMessage. value = " We're having trouble parsing weather data. "
74+ case . unableToFindLocation:
75+ errorMessage. value = " We're having trouble getting user location. "
7476 }
75-
77+
7678 location. value = emptyString
7779 iconText. value = emptyString
7880 temperature. value = emptyString
@@ -98,4 +100,8 @@ extension WeatherViewModel: LocationServiceDelegate {
98100 } )
99101 }
100102 }
103+
104+ func locationDidFail( withError error: SWError ) {
105+ self . update ( error)
106+ }
101107}
You can’t perform that action at this time.
0 commit comments