From 64319e124602107df8c5902d7d515d7c820b1931 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 1 Jun 2019 11:06:08 -0700 Subject: [PATCH] Catch invalid versions being passed in, fixes #118 --- AnkiConnect.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AnkiConnect.py b/AnkiConnect.py index 3e4b050..c82b098 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -1,5 +1,4 @@ -# Copyright (C) 2016 Alex Yatskov -# Author: Alex Yatskov +# Copyright 2016-2019 Alex Yatskov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -346,12 +345,13 @@ class AnkiConnect: raise Exception('unsupported action') else: reply['result'] = methodInst(**params) + + if version <= 4: + reply = reply['result'] + except Exception as e: reply['error'] = str(e) - if version <= 4: - reply = reply['result'] - if self.log is not None: self.log.write('[reply]\n') json.dump(reply, self.log, indent=4, sort_keys=True)