Semantics of propagated exceptions
Michael J. Fromberger
Michael.J.Fromberger at Clothing.Dartmouth.EDU
Fri Jul 21 12:46:21 EDT 2006
In article
<pan.2006.07.21.09.57.12.847175 at ID-174572.user.uni-berlin.de>,
Thomas Lotze <thomas at thomas-lotze.de> wrote:
> Suppose you have a function f which, as part of its protocol, raises some
> standard exception E under certain, well-defined circumstances. Suppose
> further that f calls other functions which may also raise E. How to best
> distinguish whether an exception E raised by f has the meaning defined by
> the protocol or just comes from details of the implementation?
My recommendation is to define your own exception type(s), and have f
raise it (them) for errors that are truly generated by f. Or, if you
really want to use one of the existing exception types, then perhaps you
can catch the exceptions from functions called by f, within f itself,
and raise some other error (or suppress the errors, if appropriate).
Cheers,
-M
--
Michael J. Fromberger | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/ | Dartmouth College, Hanover, NH, USA
More information about the Python-list
mailing list