On Thu, May 11, 2017 at 8:41 AM, Dan Stromberg <drsali...@gmail.com> wrote: > On Wed, May 10, 2017 at 1:46 PM, MRAB <pyt...@mrabarnett.plus.com> wrote: > >> NEVER use a 'bare except' to suppress exceptions! It'll catch _all_ >> exceptions, even NameError (if you've misspelled a name, it'll catch that >> too). Catch only those exceptions that you're prepared to deal with. > > When writing many kinds of applications, this is great advice. > > But is it good when writing REST API's? You don't want one buggy API > call to bring down the whole service. > > Or am I missing something?
1) You should usually use "except Exception:" rather than a bare except, even there. 2) When you create a boundary, *you log the exception*. That's what you're missing. Simply *suppressing* all exceptions is a terrible thing to do. It's common to have a web service boundary that says "except Exception as e: log_exception(e); return HTTP(500)", but that's not suppressing it, it's handling it. ChrisA -- https://mail.python.org/mailman/listinfo/python-list