Quellcode durchsuchen

catch TypeError

chenhaiyang vor 4 Jahren
Ursprung
Commit
739f76ae48
1 geänderte Dateien mit 2 neuen und 2 gelöschten Zeilen
  1. 2 2
      app/services/platform.py

+ 2 - 2
app/services/platform.py

@@ -64,7 +64,7 @@ class DataPlatformService(Service):
             if arrow.get(latest_time, TIME_FMT).shift(minutes=15) < arrow.get(self._now_time, TIME_FMT):
                 logger.info(f'delayed data - {object_id}: ({latest_time}, {latest_data})')
             value = round_half_up(latest_data, 2)
-        except KeyError and IndexError:
+        except KeyError and IndexError and TypeError:
             value = np.NAN
 
         return value
@@ -99,7 +99,7 @@ class DataPlatformService(Service):
             if arrow.get(latest_time, TIME_FMT).shift(minutes=15) < arrow.get(end_time, TIME_FMT):
                 logger.info(f'delayed data - {object_id}: ({latest_time}, {latest_data})')
             value = round_half_up(latest_data, 2)
-        except KeyError and IndexError:
+        except KeyError and IndexError and TypeError:
             value = np.NAN
 
         return value