----- Original Message ----- From: "Andrew Berg" <bahamutzero8...@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
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to