Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5138
| From | "Patty" <patty@cruzio.com> |
|---|---|
| References | <4DCAC78E.1000901@gmail.com> |
| Subject | Re: Proper way to handle errors in a module |
| Date | 2011-05-11 10:57 -0700 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1419.1305136754.9059.python-list@python.org> (permalink) |
----- Original Message ----- From: "Andrew Berg" <bahamutzero8825@gmail.com> To: <python-list@python.org> Sent: Wednesday, May 11, 2011 10:29 AM Subject: Proper way to handle errors in a module > I'm a bit new to programming outside of shell scripts (and I'm no expert > there), so I was wondering what is considered the best way to handle > errors when writing a module. Do I just let exceptions go and raise > custom exceptions for errors that don't trigger a standard one? Have the > function/method return nothing or a default value and show an error > message? I'm sure there's not a clear-cut answer, but I was just > wondering what most developers would expect a module to do in certain > situations. > -- > http://mail.python.org/mailman/listinfo/python-list > > Hi Andrew - Sometimes you want an exception come up and then use that information to take your program in some direction. For example, you might want your program to 'see' the exception that comes up when you go one beyond the end of an array. This means that something you wanted to happen within the array you set up finished successfully (the program just reached one beyond it and you didn't get an error!). The enduser doesn't need to see this displayed on the screen or in a window, you can just use an exception as-is to your advantage within the program. Regards, Patty
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Proper way to handle errors in a module "Patty" <patty@cruzio.com> - 2011-05-11 10:57 -0700
csiph-web