Table of Contents

Class Error

Namespace
Gym.Exceptions
Assembly
Gym.dll

The superclass of every error Gym.NET raises itself (as opposed to Python built-ins such as ValueError, which Gym.NET takes from NumSharp, decision D17). Catch it to handle any library-defined failure, for example an invalid seed.

public class Error : Exception, ISerializable
Inheritance
Error
Implements
Derived
Inherited Members
Extension Methods

Remarks

The error classes follow Gymnasium's hierarchy (UnregisteredEnv and its three subclasses, ResetNeeded, InvalidAction, ...); the ones Gymnasium does not derive from Error (AlreadyPendingCallError, DeprecatedWrapper, ...) do not here either. 0.2's own exceptions are obsolete bases of their Gymnasium counterparts until 2.0 (DR-58), so 0.2's catch blocks still compile: InvalidActionError under InvalidAction (the envs that assert their action raise AssertionError instead), AlreadySteppingError under AlreadyPendingCallError, NotSteppingError under NoAsyncCallError. Reference: gymnasium/error.py.

Constructors

Error()

An error without a message. Its Message is empty, as Python's str(Error()) is, rather than .NET's generic "Exception of type ... was thrown.", so messages compare verbatim with Gymnasium's.

public Error()

Error(string)

An error with Gymnasium's message, which callers and tests may match verbatim.

public Error(string message)

Parameters

message string

The message; Gym's own raise sites pass Gymnasium's text verbatim.

Error(string, Exception)

An error with a message and the exception that caused it.

public Error(string message, Exception innerException)

Parameters

message string

The message; Gym's own raise sites pass Gymnasium's text verbatim.

innerException Exception

The underlying cause.