diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index 07139a09..8d227568 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -127,7 +127,7 @@ class Controller: self.save() with open(self._config_file) as f: data = json.load(f) - except (OSError, json.decoder.JSONDecodeError) as e: + except (OSError, ValueError) as e: log.critical("Cannot load %s: %s", self._config_file, str(e)) return diff --git a/gns3server/controller/gns3vm/virtualbox_gns3_vm.py b/gns3server/controller/gns3vm/virtualbox_gns3_vm.py index 41be00b8..d1e430c8 100644 --- a/gns3server/controller/gns3vm/virtualbox_gns3_vm.py +++ b/gns3server/controller/gns3vm/virtualbox_gns3_vm.py @@ -234,7 +234,7 @@ class VirtualBoxGNS3VM(BaseGNS3VM): if resp: try: json_data = yield from resp.json() - except json.decoder.JSONDecodeError: + except ValueError: pass resp.close() diff --git a/gns3server/controller/topology.py b/gns3server/controller/topology.py index a6bd4a00..02840672 100644 --- a/gns3server/controller/topology.py +++ b/gns3server/controller/topology.py @@ -112,7 +112,7 @@ def load_topology(path): try: with open(path, encoding="utf-8") as f: topo = json.load(f) - except (OSError, UnicodeDecodeError, json.decoder.JSONDecodeError) as e: + except (OSError, UnicodeDecodeError, ValueError) as e: raise aiohttp.web.HTTPConflict(text="Could not load topology {}: {}".format(path, str(e))) if "revision" not in topo or topo["revision"] < 5: # If it's an old GNS3 file we need to convert it diff --git a/scripts/random_query.py b/scripts/random_query.py index 59d6bc9f..66e67130 100644 --- a/scripts/random_query.py +++ b/scripts/random_query.py @@ -227,7 +227,7 @@ async def main(loop): try: j = await error.response.json() die("%s %s invalid status %d:\n%s", error.method, error.path, error.response.status, json.dumps(j, indent=4)) - except (json.decoder.JSONDecodeError, aiohttp.errors.ServerDisconnectedError): + except (ValueError, aiohttp.errors.ServerDisconnectedError): die("%s %s invalid status %d", error.method, error.path, error.response.status)