Table of Contents

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

message string

The group's message (Python's message).

exceptions IEnumerable<Exception>

The members, in order; enumerated once.

Exceptions

TypeError

A null message or member sequence; a member Python counts as a BaseException only (CPython: Cannot nest BaseExceptions in an ExceptionGroup, or Cannot 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

message string

The group's message (Python's message).

innerException Exception

The 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

message is null, or innerException is a member Python counts as a BaseException only (Cannot nest BaseExceptions in an ExceptionGroup).

ValueError

innerException is null (CPython's Item 0 of second argument (exceptions) is not an exception).