Don't print duplicate error message in chrome (#1144)

In chrome, the error message is contained in the stack. Avoid printing
it twice.
This commit is contained in:
Dexter Chua 2021-01-16 20:50:40 +08:00 committed by GitHub
parent 3fef124b87
commit 293fefa7df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -52,12 +52,12 @@ class JavascriptException(Exception):
def __init__(self, msg, stack):
self.msg = msg
self.stack = stack
# In chrome the stack contains the message
if self.stack and self.stack.startswith(self.msg):
self.msg = ""
def __str__(self):
if self.stack:
return self.msg + "\n\n" + self.stack
else:
return self.msg
return "\n\n".join(x for x in [self.msg, self.stack] if x)
class SeleniumWrapper: