Skip to content

Commit 2066839

Browse files
author
Kevin D Smith
committed
Add error checks for internal action calls
1 parent 55bb621 commit 2066839

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

swat/cas/connection.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,27 @@ def _get_server_features(self):
586586

587587
info = self._raw_retrieve('builtins.serverstatus', _messagelevel='error',
588588
_apptag='UI')
589-
version = tuple([int(x) for x in info['About']['Version'].split('.')][:2])
590-
stype = info['About']['System']['OS Name'].lower()
589+
if info.severity > 1:
590+
raise SWATError(info.status)
591+
592+
try:
593+
version = tuple([int(x) for x in info['About']['Version'].split('.')][:2])
594+
stype = info['About']['System']['OS Name'].lower()
595+
except KeyError:
596+
import sys
597+
sys.stderr.write('%s\n' % info)
598+
raise
591599

592600
# Check for reflection levels feature
593601
kwargs = {}
594602
if version >= (3, 5):
595603
kwargs['showlabels'] = False
604+
596605
res = self._raw_retrieve('builtins.reflect', _messagelevel='error',
597606
_apptag='UI', action='builtins.reflect', **kwargs)
607+
if res.severity > 1:
608+
raise SWATError(res.status)
609+
598610
if [x for x in res[0]['actions'][0]['params'] if x['name'] == 'levels']:
599611
out.add('reflection-levels')
600612

0 commit comments

Comments
 (0)