Catch invalid versions being passed in, fixes #118

This commit is contained in:
Alex Yatskov 2019-06-01 11:06:08 -07:00
parent 88f49a376a
commit 64319e1246

View File

@ -1,5 +1,4 @@
# Copyright (C) 2016 Alex Yatskov <alex@foosoft.net> # Copyright 2016-2019 Alex Yatskov
# Author: Alex Yatskov <alex@foosoft.net>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -346,12 +345,13 @@ class AnkiConnect:
raise Exception('unsupported action') raise Exception('unsupported action')
else: else:
reply['result'] = methodInst(**params) reply['result'] = methodInst(**params)
except Exception as e:
reply['error'] = str(e)
if version <= 4: if version <= 4:
reply = reply['result'] reply = reply['result']
except Exception as e:
reply['error'] = str(e)
if self.log is not None: if self.log is not None:
self.log.write('[reply]\n') self.log.write('[reply]\n')
json.dump(reply, self.log, indent=4, sort_keys=True) json.dump(reply, self.log, indent=4, sort_keys=True)