Java-like exception declarations for python methods
Project description
PyCatch
PyCatch allows Java-like exception declarations for python methods.
Introduces throws
decorator and Catch
context manager and raises
UncheckedExceptionError
if declared exception is not handled.
Usage
from pycatch import throws
@throws(ZeroDivisionError)
def divide(x, y):
return x / y
divide(3, 2) # raises UncheckedExceptionError: ZeroDivisionError
from pycatch import Catch, throws
@throws(ZeroDivisionError)
def divide(x, y):
return x / y
with Catch(ZeroDivisionError):
divide(3, 2) # no exceptions
from pycatch import Catch, handlers, throws
@throws(ZeroDivisionError)
def divide(x, y):
return x / y
with Catch(ZeroDivisionError, handler=handlers.pass_):
divide(3, 0) # still no exceptions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pycatch-0.0.1.tar.gz
(4.1 kB
view hashes)