Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5147
| Date | 2011-05-11 13:14 -0500 |
|---|---|
| From | Andrew Berg <bahamutzero8825@gmail.com> |
| Subject | Re: Proper way to handle errors in a module |
| References | <4DCAC78E.1000901@gmail.com> <0CCEE1DAE6B2478CB150177F57E58B7B@mycomputer> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1421.1305137685.9059.python-list@python.org> (permalink) |
On 2011.05.11 12:57 PM, Patty wrote: > Hi Andrew - > > Sometimes you want an exception come up and then use that information to > take your > program in some direction. Right, but I'm wondering how I should handle errors in a module, where different people will want their programs to do different things when an error occurs in a function or method from my module (which is not necessarily because of a bug in my module - the calling script could send a bad parameter or some system configuration could prevent the function from doing something). On one hand, I could let almost all exceptions go unhandled and have the calling script handle them. This would force the developer of the calling script to learn all the exceptions that my module could raise (which could be really annoying if I have custom exceptions for problems that don't otherwise raise an exception). OTOH, I could handle all the exceptions and return None or some default value, but that would make it harder for the developer to make the script react appropriately.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Proper way to handle errors in a module Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-11 13:14 -0500
csiph-web