Source code for gymnasium.error

"""Set of Error classes for gymnasium."""


[docs] class Error(Exception): """Error superclass."""
# Registration errors
[docs] class UnregisteredEnv(Error): """Raised when the user requests an env from the registry that does not actually exist."""
[docs] class NamespaceNotFound(UnregisteredEnv): """Raised when the user requests an env from the registry where the namespace doesn't exist."""
[docs] class NameNotFound(UnregisteredEnv): """Raised when the user requests an env from the registry where the name doesn't exist."""
[docs] class VersionNotFound(UnregisteredEnv): """Raised when the user requests an env from the registry where the version doesn't exist."""
[docs] class DeprecatedEnv(Error): """Raised when the user requests an env from the registry with an older version number than the latest env with the same name."""
[docs] class RegistrationError(Error): """Raised when the user attempts to register an invalid env. For example, an unversioned env when a versioned env exists."""
# Environment errors
[docs] class DependencyNotInstalled(Error): """Raised when the user has not installed a dependency."""
[docs] class UnsupportedMode(Error): """Raised when the user requests a rendering mode not supported by the environment."""
[docs] class InvalidMetadata(Error): """Raised when the metadata of an environment is not valid."""
[docs] class ResetNeeded(Error): """When the order enforcing is violated, i.e. step or render is called before reset."""
[docs] class InvalidAction(Error): """Raised when the user performs an action not contained within the action space."""
[docs] class MissingArgument(Error): """Raised when a required argument in the initializer is missing."""
[docs] class InvalidProbability(Error): """Raised when given an invalid value for a probability."""
[docs] class InvalidBound(Error): """Raised when the clipping an array with invalid upper and/or lower bound."""
# Wrapper errors
[docs] class DeprecatedWrapper(ImportError): """Error message for importing an old version of a wrapper."""
# Vectorized environments errors
[docs] class AlreadyPendingCallError(Exception): """Raised when `reset`, or `step` is called asynchronously (e.g. with `reset_async`, or `step_async` respectively), and `reset_async`, or `step_async` (respectively) is called again (without a complete call to `reset_wait`, or `step_wait` respectively).""" name: str def __init__(self, message: str, name: str): """Initialises the exception with name attributes.""" super().__init__(message) self.name = name
[docs] class NoAsyncCallError(Exception): """Raised when an asynchronous `reset`, or `step` is not running, but `reset_wait`, or `step_wait` (respectively) is called.""" name: str def __init__(self, message: str, name: str): """Initialises the exception with name attributes.""" super().__init__(message) self.name = name
[docs] class ClosedEnvironmentError(Exception): """Trying to call `reset`, or `step`, while the environment is closed."""
[docs] class CustomSpaceError(Exception): """The space is a custom gymnasium.Space instance, and is not supported by `AsyncVectorEnv` with `shared_memory=True`."""