Open Lamparter opened 1 week ago
You can raise an instance of a .NET exception. For example:
>>> raise System.Runtime.InteropServices.COMException()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: Error HRESULT E_FAIL has been returned from a call to a COM component.
I guess we could also instantiate the exception when trying to raise a class derived from System.Exception
.
📄 Description
Currently, raising a .NET exception that derives from
System.Exception
using theraise
keyword results in the following error:TypeError: exceptions must derive from BaseException
. The IronPython compiler should allow exceptions from .NET classes to be raised using Python's built inraise
function.🗃️ Alternative solutions
BaseException
entirely withSystem.Exception
(best)BaseException
andSystem.Exception
to co-exist as different types of exceptions👥 Intended Use-Case
This would allow for better use of the existing CLR exception types.
📸 Assets