Error Handling in the Real World

Below you can find the video of a talk I gave yesterday at the Python Portland user group meetup. The topic of the talk is error handling. Note that I recorded the talk myself, using a screen capture software plus a voice recorder app running on my cellphone. It is a decent recording, but not professional quality by any means.

I want to thank the PDX Python user group for giving me the chance to present last night, and also to my employer SDVI Corporation for sponsoring the night and bringing in pizza. By the way, did you know SDVI is hiring remote Python/Javascript developers?


  • #1 Davide Olianas said 2016-02-27T11:37:23Z

    Hi, this was very interesting! I program as a hobbyst and I immediately noticed the resemblance of my code to the ugly try catch code mixed with the logic of the application.

    I'll definitely give a chance to merry.

    Thanks for sharing the talk!

  • #2 Igor said 2016-02-28T16:26:37Z

    Would adding merry affect performance significantly? (compared to clean exception handling in your code)

  • #3 Miguel Grinberg said 2016-02-29T02:49:28Z

    @Igor: That's very good question. All merry does is apply the technique I explain in the talk of moving the error handlers as high in the call stack as possible, so no, there is nothing magical going on, or any kind of background work. It is effectively the same as wrapping the function call manually with a try except block.

  • #4 Mark said 2016-03-13T14:42:31Z

    Excellent! As you mentioned, this is a topic that typically isn't addressed as thoroughly as it should be. I like this approach - very pythonic. ;)

  • #5 cizzit said 2016-03-27T09:41:49Z

    Love your talks. I'm re-writing an old web.py app in Flask and this is a perfect time to give merry a shot. I'm trying to add the @merry._try to a route and while I get the message I enter in the _except() area, I can't get it to redirect a page if the except is called: instead it goes ahead with the original Flask behaviour (either a HTTP500 code or the debugger). Also the stacktrace is showing in the console regardless of any logger settings I set when initialising the merry object. How could I get this working?

  • #6 Miguel Grinberg said 2016-03-28T05:38:10Z

    @cizzit: Not sure you need merry when you are using Flask. The same type of error protection is implemented by Flask directly, through the errorhandler decorator. So I think you are going to see some competition between merry and Flask itself in trying to handle errors.

    But, in any case, your comment made me realize that merry wasn't handling returned values correctly, so I have made some fixes regarding that, available in the 0.2.0 release.

  • #7 cizzit said 2016-04-01T04:58:21Z

    Thanks, Miguel. I thought that might be the case, but I was very interested in merry and am currently building flask apps for work so i thought I'd give it a go.

    I'll definitely keep it in my arsenal for future works :)

  • #8 Frank said 2016-07-13T22:18:56Z

    Thank you for sharing. Just recently started using Python for scripting, retrieving records from our AS400. Peers are using java, batch file and vbscript. I can do it all using only Python. Looking forward to adding merry to my tool kit.

Leave a Comment