Class ExceptionGroup
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
Python's ExceptionGroup: a BaseExceptionGroup whose members are all Python
Exceptions, the group ordinary code raises and catches (except*).
public class ExceptionGroup : BaseExceptionGroup, ISerializable, INumSharpException
- Inheritance
-
ExceptionGroup
- Implements
- Inherited Members
Remarks
Python's MRO is ExceptionGroup → BaseExceptionGroup, Exception; NumSharp's derives from
BaseExceptionGroup (and so from .NET's AggregateException).
It refuses a KeyboardInterrupt, SystemExit, GeneratorExit or a
non-ExceptionGroup group as a member, as Python's does (Cannot nest BaseExceptions in an
ExceptionGroup); build a BaseExceptionGroup for those, or let
Create(string, IEnumerable<Exception>) choose.
Constructors
ExceptionGroup(string, IEnumerable<Exception>)
Python's ExceptionGroup(message, exceptions).
public ExceptionGroup(string message, IEnumerable<Exception> exceptions)
Parameters
messagestringThe group's message (Python's
message).exceptionsIEnumerable<Exception>The members, in order; enumerated once.
Exceptions
- TypeError
A null message or member sequence; a member Python counts as a
BaseExceptiononly (CPython:Cannot nest BaseExceptions in an ExceptionGroup, orCannot nest BaseExceptions in 'MyGroup'for a subclass).- ValueError
An empty member sequence, or a null member.
ExceptionGroup(string, Exception)
.NET's standard (message, innerException) constructor every NumSharp exception has, with
AggregateException's meaning: innerException becomes the group's one member
(Python's ExceptionGroup(message, [innerException])), reading message (1 sub-exception).
public ExceptionGroup(string message, Exception innerException)
Parameters
messagestringThe group's message (Python's
message).innerExceptionExceptionThe group's only member.
Remarks
Goes through the sequence constructor, so every check of Python's class applies. Footgun:
new ExceptionGroup("m", null) does not compile (both two-argument constructors accept a null); cast it
to IEnumerable<Exception> for Python's ExceptionGroup("m", None).
Exceptions
- TypeError
messageis null, orinnerExceptionis a member Python counts as aBaseExceptiononly (Cannot nest BaseExceptions in an ExceptionGroup).- ValueError
innerExceptionis null (CPython'sItem 0 of second argument (exceptions) is not an exception).