Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107396 > unrolled thread
| Started by | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| First post | 2016-04-19 23:09 -0700 |
| Last post | 2016-04-19 23:09 -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.
Re: How much sanity checking is required for function inputs? Ethan Furman <ethan@stoneleaf.us> - 2016-04-19 23:09 -0700
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2016-04-19 23:09 -0700 |
| Subject | Re: How much sanity checking is required for function inputs? |
| Message-ID | <mailman.15.1461132516.12923.python-list@python.org> |
On 04/19/2016 10:51 PM, Stephen Hansen wrote: > But that's a fuzzy question, there's no solid and clear answer. Did you > see Ethan's response? I largely agree with his trinity: > > On Sun, Apr 17, 2016, at 10:26 PM, Ethan Furman wrote: >> I sanity check for three reasons: >> >> 1) raise a nicer error message >> >> 2) keep the point of failure close to the error >> >> 3) the consequences of bad data are Bad Bad Things (tm) > > With a 4)th that exceptions aren't for users, only programmers. But > ultimately, I'd rather a user see an exception if something weird goes > wrong because they can send it to me and I can diagnose it and push an > update. So I also: > > 4) Attempt to make sure all user errors result in user error messages, > not exceptions. > > Note, 1) doesn't mean I always raise a nicer message, it means if > "KeyError" is ambiguious or odd, I raise a better and more informative > one. But you're getting nothing swapping out KeyError for > Exception(lotsofwords). > > I use 1) more to be less 'nicer' and more, er, 'more specific'. Since I > don't like exceptions to rise to the user level where niceness is > needed. Yeah, that's a better phrasing for (1); I meant more appropriate or informative, such as swapping an internal error (such as KeyError) for a more meaningful FieldNotFound error (or whatever) -- largely library code concerns. -- ~Ethan~
Back to top | Article view | comp.lang.python
csiph-web