From 0e8116b74360d8faa47ddead6896c339413f79aa Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 15 Dec 2019 17:44:31 +0100 Subject: [PATCH] handle errors in json files --- owrx/bands.py | 3 +++ owrx/bookmarks.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/owrx/bands.py b/owrx/bands.py index 3ee5a5f..cf2bd7c 100644 --- a/owrx/bands.py +++ b/owrx/bands.py @@ -57,6 +57,9 @@ class Bandplan(object): return [Band(d) for d in bands_json] except FileNotFoundError: pass + except json.JSONDecodeError: + logger.exception("error while parsing bandplan from %s", file) + return [] return [] def findBands(self, freq): diff --git a/owrx/bookmarks.py b/owrx/bookmarks.py index 2b4925e..3e90a85 100644 --- a/owrx/bookmarks.py +++ b/owrx/bookmarks.py @@ -1,5 +1,9 @@ import json +import logging + +logger = logging.getLogger(__name__) + class Bookmark(object): def __init__(self, j): @@ -45,6 +49,9 @@ class Bookmarks(object): return [Bookmark(d) for d in bookmarks_json] except FileNotFoundError: pass + except json.JSONDecodeError: + logger.exception("error while parsing bookmarks from %s", file) + return [] return []