diff --git a/LesmillsNZ WatchKit Extension/TimetableRequest.swift b/LesmillsNZ WatchKit Extension/TimetableRequest.swift index d2e1e87..02467c4 100644 --- a/LesmillsNZ WatchKit Extension/TimetableRequest.swift +++ b/LesmillsNZ WatchKit Extension/TimetableRequest.swift @@ -35,20 +35,27 @@ func createTimetableRequest( // Handle the request. guard let data = data else { - let errMessage = "\u{2297} \(error?.localizedDescription ?? "Unknown Error")" - callbackFunc([:], errMessage) - print(errMessage) + let err = "\u{2297} \(error?.localizedDescription ?? "Unknown Error")" + // error: run callback func. + print(err) + callbackFunc([:], err) return } let responseJSON = try? JSONSerialization.jsonObject(with: data, options: []) if let responseJSON = responseJSON as? [String: Any] { guard let responseData = responseJSON["responseData"] as? [String:Any] else { - print("--- responseData key missing...!") + let err = "Error: \"responseData\" key missing...!" + // error: run callback func. + print(err) + callbackFunc([:], err) return } guard let cards = responseData["cards"] as? [[String:Any]] else { - print("--- cards key missing...!") + let err = "Error: \"cards\" key missing...!" + // error: run callback func. + print(err) + callbackFunc([:], err) return } @@ -62,7 +69,7 @@ func createTimetableRequest( timetableData[fitnessClass.dateKey!, default: []].append(fitnessClass) } } catch { - print("FitnessClass mapping failed") + print("Error: FitnessClass mapping failed") } } } diff --git a/LesmillsNZ WatchKit Extension/Views/WeekListView.swift b/LesmillsNZ WatchKit Extension/Views/WeekListView.swift index 972ba39..c92e846 100644 --- a/LesmillsNZ WatchKit Extension/Views/WeekListView.swift +++ b/LesmillsNZ WatchKit Extension/Views/WeekListView.swift @@ -73,7 +73,16 @@ struct WeekListView: View { Button(action: model.makeDataRequest) { ReloadView() } - // no data message. + + // Error message display. + if (model.requestError != nil) { + Text(model.requestError!) + .foregroundColor(Color(hex:"#ed4e4e")) + .font(.system(size: 12)) + .padding() + } + + // No data message. if (keyLabels.count == 0) { Text("No timetable data avaliable please try reloading.") .foregroundColor(Color.gray) diff --git a/LesmillsNZ.xcodeproj/project.xcworkspace/xcuserdata/jchan.xcuserdatad/UserInterfaceState.xcuserstate b/LesmillsNZ.xcodeproj/project.xcworkspace/xcuserdata/jchan.xcuserdatad/UserInterfaceState.xcuserstate index ed78896..e0d57d3 100644 Binary files a/LesmillsNZ.xcodeproj/project.xcworkspace/xcuserdata/jchan.xcuserdatad/UserInterfaceState.xcuserstate and b/LesmillsNZ.xcodeproj/project.xcworkspace/xcuserdata/jchan.xcuserdatad/UserInterfaceState.xcuserstate differ