Class KeyError
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
Exception that corresponds to Python/NumPy's KeyError. Raised when a mapping (dict) key is not found.
public class KeyError : NumSharpException, ISerializable, INumSharpException
- Inheritance
-
KeyError
- Implements
- Inherited Members
Remarks
Mirrors Python's KeyError for API compatibility. In NumSharp this is raised where NumPy
itself raises KeyError — notably np.einsum_path(..., optimize="<unknown>"),
which reaches einsumfunc.py's raise KeyError("Path name %s not found", path_type).
The message is used verbatim: Python's KeyError.__str__ quotes a lone argument
(str(KeyError('a')) is "'a'"), so a port that wants Python's text passes it already quoted.
Constructors
KeyError()
Creates the error with Python's text for a bare raise KeyError: an empty
Message, as str(KeyError()) is ''.
public KeyError()
Remarks
ToString() then starts with the class name alone, as Python's traceback prints a
bare KeyError; prefer a message that names the missing key.
KeyError(string)
Creates the error with NumPy's (or the port's) message.
public KeyError(string message)
Parameters
messagestringThe text, verbatim: Python's
str()of the error.
KeyError(string, Exception)
Creates the error with a message and the exception that caused it: Python's raise KeyError(message) from
innerException, the cause kept in InnerException as Python keeps it in
cause.
public KeyError(string message, Exception innerException)