| Maintainer | John Goerzen, |
|---|
Python.Exceptions
Contents
Description
Maintainer : [email protected] Stability : provisional Portability: portable
Python low-level exception handling
Written by John Goerzen, [email protected]
- data PyException
- catchPy :: IO a -> (PyException -> IO a) -> IO a
- handlePy :: (PyException -> IO a) -> IO a -> IO a
- pyExceptions :: Exception -> Maybe PyException
- catchSpecificPy :: PyObject -> IO a -> (PyException -> IO a) -> IO a
- formatException :: PyException -> IO PyException
- doesExceptionMatch :: PyException -> PyObject -> IO Bool
- exc2ioerror :: PyException -> IO a
Types
General Catching
catchPy :: IO a -> (PyException -> IO a) -> IO aSource
Execute the given IO action.
If it raises a PyException, then execute the supplied handler and return
its return value. Otherwise, process as normal.
handlePy :: (PyException -> IO a) -> IO a -> IO aSource
Like catchPy, with the order of arguments reversed.
pyExceptions :: Exception -> Maybe PyExceptionSource
Useful as the first argument to catchJust, tryJust, or handleJust.
Return Nothing if the given exception is not a PyException, or
the exception otherwise.
Catching of specific Python exceptions
catchSpecificPy :: PyObject -> IO a -> (PyException -> IO a) -> IO aSource
Like catchPy, but catches only instances of the Python class given
(see doesExceptionMatch).
Exception Object Operations
formatException :: PyException -> IO PyExceptionSource
When an exception is thrown, it is not immediately formatted.
This call will format it.
doesExceptionMatch :: PyException -> PyObject -> IO BoolSource
Returns true if the passed PyException matches the given Python
exception class or one of its subclasses. Standard Python exception classes
are given in Python.Exceptions.ExcTypes.
Re-Raising Exceptions
exc2ioerror :: PyException -> IO aSource