Skip to content

robot.api.exceptions

Exceptions that libraries can use for communicating failures and other events.

These exceptions can be imported also via the top level :mod:robot.api package like from robot.api import SkipExecution.

This module and all exceptions are new in Robot Framework 4.0.

Failure

Failure(message: str, html: bool = False)

Bases: AssertionError

Report failed validation.

There is no practical difference in using this exception compared to using the standard AssertionError. The main benefits are HTML support and that the name of this exception is consistent with other exceptions in this module.

:param message: Exception message. :param html: When True, message is considered to be HTML and not escaped.

Source code in src/robot/api/exceptions.py
def __init__(self, message: str, html: bool = False):
    """
    :param message: Exception message.
    :param html: When ``True``, message is considered to be HTML and not escaped.
    """
    super().__init__(message if not html else '*HTML* ' + message)

ContinuableFailure

ContinuableFailure(message: str, html: bool = False)

Bases: Failure

Report failed validation but allow continuing execution.

:param message: Exception message. :param html: When True, message is considered to be HTML and not escaped.

Source code in src/robot/api/exceptions.py
def __init__(self, message: str, html: bool = False):
    """
    :param message: Exception message.
    :param html: When ``True``, message is considered to be HTML and not escaped.
    """
    super().__init__(message if not html else '*HTML* ' + message)

Error

Error(message: str, html: bool = False)

Bases: RuntimeError

Report error in execution.

Failures related to the system not behaving as expected should typically be reported using the :class:Failure exception or the standard AssertionError. This exception can be used, for example, if the keyword is used incorrectly.

There is no practical difference in using this exception compared to using the standard RuntimeError. The main benefits are HTML support and that the name of this exception is consistent with other exceptions in this module.

:param message: Exception message. :param html: When True, message is considered to be HTML and not escaped.

Source code in src/robot/api/exceptions.py
def __init__(self, message: str, html: bool = False):
    """
    :param message: Exception message.
    :param html: When ``True``, message is considered to be HTML and not escaped.
    """
    super().__init__(message if not html else '*HTML* ' + message)

FatalError

FatalError(message: str, html: bool = False)

Bases: Error

Report error that stops the whole execution.

:param message: Exception message. :param html: When True, message is considered to be HTML and not escaped.

Source code in src/robot/api/exceptions.py
def __init__(self, message: str, html: bool = False):
    """
    :param message: Exception message.
    :param html: When ``True``, message is considered to be HTML and not escaped.
    """
    super().__init__(message if not html else '*HTML* ' + message)

SkipExecution

SkipExecution(message: str, html: bool = False)

Bases: Exception

Mark the executed test or task skipped.

:param message: Exception message. :param html: When True, message is considered to be HTML and not escaped.

Source code in src/robot/api/exceptions.py
def __init__(self, message: str, html: bool = False):
    """
    :param message: Exception message.
    :param html: When ``True``, message is considered to be HTML and not escaped.
    """
    super().__init__(message if not html else '*HTML* ' + message)