|
@@ -193,8 +193,25 @@ extension MainViewController {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ var entriesResponse: [ShareGlucoseData]?
|
|
|
let decoder = JSONDecoder()
|
|
let decoder = JSONDecoder()
|
|
|
- let entriesResponse = try? decoder.decode([ShareGlucoseData].self, from: data)
|
|
|
|
|
|
|
+ do {
|
|
|
|
|
+ entriesResponse = try decoder.decode([ShareGlucoseData].self, from: data)
|
|
|
|
|
+ } catch let DecodingError.dataCorrupted(context) {
|
|
|
|
|
+ print("Data corrupted: \(context)")
|
|
|
|
|
+ } catch let DecodingError.keyNotFound(key, context) {
|
|
|
|
|
+ print("Key '\(key)' not found: \(context.debugDescription)")
|
|
|
|
|
+ print("codingPath: \(context.codingPath)")
|
|
|
|
|
+ } catch let DecodingError.valueNotFound(value, context) {
|
|
|
|
|
+ print("Value '\(value)' not found: \(context.debugDescription)")
|
|
|
|
|
+ print("codingPath: \(context.codingPath)")
|
|
|
|
|
+ } catch let DecodingError.typeMismatch(type, context) {
|
|
|
|
|
+ print("Type '\(type)' mismatch: \(context.debugDescription)")
|
|
|
|
|
+ print("codingPath: \(context.codingPath)")
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ print("Error decoding JSON: \(error)")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if var nsData = entriesResponse {
|
|
if var nsData = entriesResponse {
|
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
|
// transform NS data to look like Dex data
|
|
// transform NS data to look like Dex data
|