Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failure exceptiontype in output.xml #3673

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/robot/output/loggerhelper.py
Expand Up @@ -49,30 +49,31 @@ def info(self, msg):
def warn(self, msg):
self.write(msg, 'WARN')

def fail(self, msg):
def fail(self, msg, error_type=None):
html = False
if msg.startswith("*HTML*"):
html = True
msg = msg[6:].lstrip()
self.write(msg, 'FAIL', html)
self.write(msg, 'FAIL', html, error_type)

def error(self, msg):
self.write(msg, 'ERROR')

def write(self, message, level, html=False):
self.message(Message(message, level, html))
def write(self, message, level, html=False, error_type=None):
self.message(Message(message, level, html, error_type=error_type))

def message(self, msg):
raise NotImplementedError(self.__class__)


class Message(BaseMessage):
__slots__ = ['_message']
__slots__ = ['_message', 'error_type']

def __init__(self, message, level='INFO', html=False, timestamp=None):
def __init__(self, message, level='INFO', html=False, timestamp=None, error_type=None):
message = self._normalize_message(message)
level, html = self._get_level_and_html(level, html)
timestamp = timestamp or get_timestamp()
self.error_type=error_type
BaseMessage.__init__(self, message, level, html, timestamp)

def _normalize_message(self, msg):
Expand Down
2 changes: 2 additions & 0 deletions src/robot/output/xmllogger.py
Expand Up @@ -58,6 +58,8 @@ def log_message(self, msg):

def _write_message(self, msg):
attrs = {'timestamp': msg.timestamp or 'N/A', 'level': msg.level}
if msg.error_type:
attrs['exceptiontype'] = msg.error_type.__name__
if msg.html:
attrs['html'] = 'yes'
self._writer.element('msg', msg.message, attrs)
Expand Down
4 changes: 2 additions & 2 deletions src/robot/running/context.py
Expand Up @@ -194,5 +194,5 @@ def info(self, message):
def warn(self, message):
self.output.warn(message)

def fail(self, message):
self.output.fail(message)
def fail(self, message, error_type=None):
self.output.fail(message, error_type)
2 changes: 1 addition & 1 deletion src/robot/running/statusreporter.py
Expand Up @@ -69,7 +69,7 @@ def _get_failure(self, exc_type, exc_value, exc_tb, context):
failure = HandlerExecutionFailed(ErrorDetails(exc_info))
if failure.timeout:
context.timeout_occurred = True
context.fail(failure.full_message)
context.fail(failure.full_message, exc_type)
if failure.traceback:
context.debug(failure.traceback)
return failure