Skip to content

Commit 51dfe0a

Browse files
added exception catching to context switching in Keyword.__call__ and added for loop breaks on session and context switching errors
--HG-- branch : draft
1 parent 1cde6db commit 51dfe0a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

robottools/library/keywords/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ def __call__(self, *args, **kwargs):
154154
switch(sname)
155155
except hcls.SessionError as exc:
156156
error = exc
157+
# don't switch any more sessions
158+
break
157159
# only perform explicit context switching
158160
# if explicit session switching didn't raise any error
159161
if error is not None:
@@ -171,7 +173,12 @@ def __call__(self, *args, **kwargs):
171173
self.libinstance, identifier)
172174
switch = getattr(self.libinstance,
173175
'switch_' + identifier)
174-
switch(ctxname)
176+
try:
177+
switch(ctxname)
178+
except hcls.ContextError as exc:
179+
error = exc
180+
# don't switch any more contexts
181+
break
175182
# Look for arg type specs:
176183
if func.argtypes:
177184
casted = []

0 commit comments

Comments
 (0)