Table of Contents

Class SystemExit

Namespace
NumSharp
Assembly
NumSharp.dll

Python's SystemExit: sys.exit(code), a request to end the program with an exit status (code).

public class SystemExit : NumSharpException, ISerializable, INumSharpException
Inheritance
SystemExit
Implements
Inherited Members

Remarks

In Python it sits beside Exception under BaseException, so except Exception does not catch it. C# has one root: NumSharp's derives from NumSharpException, and footgun, a catch (Exception) DOES catch it. Code that must let it through filters it out (catch (Exception e) when (e is not SystemExit)).

NumSharp never raises it, and throwing it does not end the process: a port that wants Python's behaviour catches it at the top and calls Exit(int) with code (an int as is, None as 0, anything else printed and 1, as CPython does).

Constructors

SystemExit()

Python's sys.exit(): an empty Message and a null code, as str(SystemExit()) is '' and its code is None (exit status 0).

public SystemExit()

SystemExit(object)

Python's sys.exit(code): the exit status (an int) or any other object. The message is Python's str(code) (3, True, None).

public SystemExit(object code)

Parameters

code object

The exit status or object, or null for None.

Exceptions

ValueError

code is a Python int (BigInteger) of more than 4300 decimal digits, whose str() CPython refuses.

SystemExit(string)

Python's sys.exit(text): the text is both the message and code (CPython prints it to stderr and exits with status 1).

public SystemExit(string message)

Parameters

message string

The text, or null for Python's SystemExit(None) (message None, code null).

SystemExit(string, Exception)

Creates the error with a message and the exception that caused it: Python's raise SystemExit(message) from innerException, the cause kept in InnerException; the message is also code.

public SystemExit(string message, Exception innerException)

Parameters

message string

The text, verbatim.

innerException Exception

The exception that led to this one, or null for none.

Properties

code

The exit status or object (Python's code): the constructor's argument, or null after the bare constructor (Python's None, exit status 0).

public object code { get; }

Property Value

object