Skip to content

robot.utils.error

get_error_message

get_error_message()

Returns error message of the last occurred exception.

This method handles also exceptions containing unicode messages. Thus it MUST be used to get messages from all exceptions originating outside the framework.

Source code in src/robot/utils/error.py
def get_error_message():
    """Returns error message of the last occurred exception.

    This method handles also exceptions containing unicode messages. Thus it
    MUST be used to get messages from all exceptions originating outside the
    framework.
    """
    return ErrorDetails().message

get_error_details

1
2
3
4
get_error_details(
    full_traceback=True,
    exclude_robot_traces=EXCLUDE_ROBOT_TRACES,
)

Returns error message and details of the last occurred exception.

Source code in src/robot/utils/error.py
def get_error_details(full_traceback=True, exclude_robot_traces=EXCLUDE_ROBOT_TRACES):
    """Returns error message and details of the last occurred exception."""
    details = ErrorDetails(full_traceback=full_traceback,
                           exclude_robot_traces=exclude_robot_traces)
    return details.message, details.traceback

ErrorDetails

1
2
3
4
5
ErrorDetails(
    error=None,
    full_traceback=True,
    exclude_robot_traces=EXCLUDE_ROBOT_TRACES,
)

Object wrapping the last occurred exception.

It has attributes message, traceback, and error, where message contains the message with possible generic exception name removed, traceback contains the traceback and error contains the original error instance.

Source code in src/robot/utils/error.py
def __init__(self, error=None, full_traceback=True,
             exclude_robot_traces=EXCLUDE_ROBOT_TRACES):
    if not error:
        error = sys.exc_info()[1]
    if isinstance(error, RERAISED_EXCEPTIONS):
        raise error
    self.error = error
    self._full_traceback = full_traceback
    self._exclude_robot_traces = exclude_robot_traces
    self._message = None
    self._traceback = None