Przeglądaj źródła

Adjust error case

Deniz Cengiz 1 rok temu
rodzic
commit
af736508c8
1 zmienionych plików z 3 dodań i 2 usunięć
  1. 3 2
      Model/JSONImporter.swift

+ 3 - 2
Model/JSONImporter.swift

@@ -9,6 +9,7 @@ enum JSONImporterError: Error {
     case suspendResumePumpEventMismatch
     case suspendResumePumpEventMismatch
     case duplicatePumpEvents
     case duplicatePumpEvents
     case missingCarbsValueInCarbEntry
     case missingCarbsValueInCarbEntry
+    case missingRequiredPropertyInDetermination
 }
 }
 
 
 // MARK: - JSONImporter Class
 // MARK: - JSONImporter Class
@@ -311,8 +312,7 @@ class JSONImporter {
         guard let enactedDeliverAt = enactedDetermination.deliverAt,
         guard let enactedDeliverAt = enactedDetermination.deliverAt,
               let suggestedDeliverAt = suggestedDetermination.deliverAt
               let suggestedDeliverAt = suggestedDetermination.deliverAt
         else {
         else {
-            // TODO: adjust error
-            throw JSONImporterError.missingGlucoseValueInGlucoseEntry
+            throw JSONImporterError.missingRequiredPropertyInDetermination
         }
         }
 
 
         guard checkDeterminationDate(enactedDeliverAt), checkDeterminationDate(suggestedDeliverAt) else {
         guard checkDeterminationDate(enactedDeliverAt), checkDeterminationDate(suggestedDeliverAt) else {
@@ -609,6 +609,7 @@ extension Determination: Codable {
     /// Helper function to convert `Determination` to `OrefDetermination` while importing JSON glucose entries
     /// Helper function to convert `Determination` to `OrefDetermination` while importing JSON glucose entries
     func store(in context: NSManagedObjectContext) throws {
     func store(in context: NSManagedObjectContext) throws {
         // TODO: some guards here ?!
         // TODO: some guards here ?!
+        
         let newOrefDetermination = OrefDetermination(context: context)
         let newOrefDetermination = OrefDetermination(context: context)
         newOrefDetermination.id = UUID()
         newOrefDetermination.id = UUID()
         newOrefDetermination.insulinSensitivity = decimalToNSDecimalNumber(isf)
         newOrefDetermination.insulinSensitivity = decimalToNSDecimalNumber(isf)