Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5138 > unrolled thread

Re: Proper way to handle errors in a module

Started by"Patty" <patty@cruzio.com>
First post2011-05-11 10:57 -0700
Last post2011-05-11 10:57 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Proper way to handle errors in a module "Patty" <patty@cruzio.com> - 2011-05-11 10:57 -0700

#5138 — Re: Proper way to handle errors in a module

From"Patty" <patty@cruzio.com>
Date2011-05-11 10:57 -0700
SubjectRe: Proper way to handle errors in a module
Message-ID<mailman.1419.1305136754.9059.python-list@python.org>
----- 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 

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web