simplebench.exceptions package🔗

Custom exceptions for the simplebench package.

class simplebench.exceptions.ErrorTag(value)[source]🔗

Bases: str, Enum

Base class for error tag enums.

ErrorTags are used to identify specific error condition sources in the simplebench package.

Tests use these tags to assert specific error condition paths.

exception simplebench.exceptions.SimpleBenchArgumentError(
argument_name: str | None,
message: str,
*,
tag: ErrorTag,
)[source]🔗

Bases: TaggedException[ArgumentError]

Base class for re-raising all SimpleBench ArgumentError errors.

It is designed to be used in places where an argparse.ArgumentError would be appropriate and for re-raising ArgumentErrors caught from argparse operations.

It differs from a argparse.ArgumentError by the addition of a tag code used to very specifically identify where the error was thrown in the code for testing and development support and by directly setting the argument_name property to the name of the argument that caused the error. This is because the argparse.ArgumentError constructor expects an argparse.Action instance as the first argument and that is not always available when re-raising the exception.

This tag code does not have a direct semantic meaning except to identify the specific code throwing the exception for tests.

Usage:
raise SimpleBenchArgumentError(argument_name=”my-arg”,

message=”An error occurred”, tag=MyErrorTags.SOME_ERROR)

Parameters:
  • argument_name (str | None) – The argument name.

  • message (str) – The error message.

  • tag (ErrorTag) – The tag code.

Initializes the exception with a mandatory tag.

Parameters:
  • *args – Positional arguments to pass to the base exception’s constructor.

  • tag (Enum, keyword) – An Enum member representing the error code.

  • **kwargs – Keyword arguments to pass to the base exception’s constructor.

exception simplebench.exceptions.SimpleBenchAttributeError(
msg: str,
*,
tag: ErrorTag,
name: str | None = None,
obj: object = Ellipsis,
)[source]🔗

Bases: TaggedException[AttributeError]

Base class for all SimpleBench attribute errors.

It differs from a standard AttributeError by the addition of a tag code used to very specifically identify where the error was thrown in the code for testing and development support.

This tag code does not have a direct semantic meaning except to identify the specific code throwing the exception for tests.

Usage:

raise SimpleBenchAttributeError(“An error occurred”, tag=MyErrorTags.SOME_ERROR)

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

  • name (str | None) – The attribute name.

  • obj (object) – The object the attribute was not found on.

Raises a SimpleBenchAttributeError with the given message, name, obj, and tag.

Parameters:
  • msg (str) – The error message.

  • name (str | None) – The attribute name.

  • obj (object) – The object the attribute was not found on.

  • tag (ErrorTag) – The tag code.

exception simplebench.exceptions.SimpleBenchBenchmarkError(
msg: str,
*,
tag: ErrorTag,
)[source]🔗

Bases: TaggedException[RuntimeError]

Exceptions raised for benchmark execution errors.

If an exception occurs during the execution of a benchmark, it can be wrapped in a SimpleBenchBenchmarkError to provide additional context and tagging.

Usage:
raise SimpleBenchBenchmarkError(“An error occurred”,

tag=MyErrorTags.SOME_ERROR)

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

Raises a SimpleBenchBenchmarkError with the given message and tag.

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

exception simplebench.exceptions.SimpleBenchImportError(
msg: str,
*,
tag: ErrorTag,
)[source]🔗

Bases: TaggedException[ImportError]

Base class for all SimpleBench import errors.

It differs from a standard ImportError by the addition of a tag code used to very specifically identify where the error was thrown in the code for testing and development support.

This tag code does not have a direct semantic meaning except to identify the specific code throwing the exception for tests.

Usage:

raise SimpleBenchImportError(“An error occurred”, tag=MyErrorTags.SOME_ERROR)

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

Raises a SimpleBenchImportError with the given message and tag.

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

exception simplebench.exceptions.SimpleBenchKeyError(
msg: str,
*,
tag: ErrorTag,
)[source]🔗

Bases: TaggedException[KeyError]

Base class for all SimpleBench key errors.

It differs from a standard KeyError by the addition of a tag code used to very specifically identify where the error was thrown in the code for testing and development support.

This tag code does not have a direct semantic meaning except to identify the specific code throwing the exception for tests.

Usage:

raise SimpleBenchKeyError(“An error occurred”, tag=MyErrorTags.SOME_ERROR)

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

Raises a SimpleBenchKeyError with the given message and tag.

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

exception simplebench.exceptions.SimpleBenchNotImplementedError(
msg: str,
*,
tag: ErrorTag,
)[source]🔗

Bases: TaggedException[NotImplementedError]

Base class for all SimpleBench not implemented errors.

It differs from a standard NotImplementedError by the addition of a tag code used to very specifically identify where the error was thrown in the code for testing and development support.

This tag code does not have a direct semantic meaning except to identify the specific code throwing the exception for tests.

Usage:

raise SimpleBenchNotImplementedError(“An error occurred”, tag=MyErrorTags.SOME_ERROR)

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

Raises a SimpleBenchNotImplementedError with the given message and tag.

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

exception simplebench.exceptions.SimpleBenchRuntimeError(
msg: str,
*,
tag: ErrorTag,
)[source]🔗

Bases: TaggedException[RuntimeError]

Base class for all SimpleBench runtime errors.

It differs from a standard RuntimeError by the addition of a tag code used to very specifically identify where the error was thrown in the code for testing and development support.

This tag code does not have a direct semantic meaning except to identify the specific code throwing the exception for tests.

Usage:

raise SimpleBenchRuntimeError(“An error occurred”, tag=MyErrorTags.SOME_ERROR)

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

Raises a SimpleBenchRuntimeError with the given message and tag.

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

exception simplebench.exceptions.SimpleBenchTypeError(
msg: str,
*,
tag: ErrorTag,
)[source]🔗

Bases: TaggedException[ValueError]

Base class for all SimpleBench type errors.

It differs from a standard TypeError by the addition of a tag code used to very specifically identify where the error was thrown in the code for testing and development support.

This tag code does not have a direct semantic meaning except to identify the specific code throwing the exception for tests.

Usage:

raise SimpleBenchTypeError(“An error occurred”, tag=MyErrorTags.SOME_ERROR)

Parameters:
  • msg (str, positional) – The error message.

  • tag (ErrorTag) – The tag code.

Raises a SimpleBenchTypeError with the given message and tag.

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

exception simplebench.exceptions.SimpleBenchValueError(
msg: str,
*,
tag: ErrorTag,
)[source]🔗

Bases: TaggedException[ValueError]

Base class for all SimpleBench value errors.

It differs from a standard ValueError by the addition of a tag code used to very specifically identify where the error was thrown in the code for testing and development support.

This tag code does not have a direct semantic meaning except to identify the specific code throwing the exception for tests.

Usage:

raise SimpleBenchValueError(“An error occurred”, tag=MyErrorTags.SOME_ERROR)

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

Raises a SimpleBenchValueError with the given message and tag.

Parameters:
  • msg (str) – The error message.

  • tag (ErrorTag) – The tag code.

exception simplebench.exceptions.TaggedException(
*args: Any,
tag: Enum,
**kwargs: Any,
)[source]🔗

Bases: Exception, Generic[E]

A generic exception that can be specialized with a base exception type and requires a tag during instantiation.

This class extends the built-in Exception class and adds a mandatory tag attribute. The tag is intended to provide additional context or categorization for the exception.

The tag must be an instance of Enum to ensure a controlled set of possible tags and must be the first argument provided during instantiation if passed positionally.

It is used by other exceptions in the simplebench package to provide standardized error tagging for easier identification and handling of specific error conditions. and is used to create exceptions with specific tags for error handling and identification. with this base class.

Example:

class MyTaggedException(TaggedException[ValueError]): ‘’’A tagged exception that is a specialized ValueError.’’’

raise MyTaggedException(“An error occurred”, tag=MyErrorTags.SOME_ERROR)

Parameters:
  • tag (Enum, keyword) – An Enum member representing the error code.

  • *args – Positional arguments to pass to the base exception’s constructor.

  • **kwargs – Keyword arguments to pass to the base exception’s constructor.

tag_code🔗

Enum

Initializes the exception with a mandatory tag.

Parameters:
  • *args – Positional arguments to pass to the base exception’s constructor.

  • tag (Enum, keyword) – An Enum member representing the error code.

  • **kwargs – Keyword arguments to pass to the base exception’s constructor.

Submodules🔗