Re: Python doesn't catch exceptions ?

2017-02-01 Thread Ian Kelly
On Wed, Feb 1, 2017 at 8:11 AM, Ivo Bellin Salarin wrote: > This code generates instead the messages: > ``` > ERROR 47.135[bigquery.py.create_table:362] caught exception: HttpError, > defined in server/libs/googleapiclient/errors.pyc. we are in > /Users/nilleb/dev/gae-sample-project/app > ERROR 47

Re: Python doesn't catch exceptions ?

2017-02-01 Thread Peter Otten
Ivo Bellin Salarin wrote: > Hi all, > > I have a curious problem with Python exceptions. > > The following code doesn't catch HttpError: > ``` > from server.libs.googleapiclient.errors import HttpError > [..] > try: > OAuth.backoffExec(request) > return True > except Http

Python doesn't catch exceptions ?

2017-02-01 Thread Ivo Bellin Salarin
Hi all, I have a curious problem with Python exceptions. The following code doesn't catch HttpError: ``` from server.libs.googleapiclient.errors import HttpError [..] try: OAuth.backoffExec(request) return True except HttpError as e: return e.resp.status == 404

Re: Catch exceptions

2006-02-27 Thread Jonathan Gardner
(A) You'll have to be more specific about your problem if you want us to help. Under which circumstances did it work or not? What exactly is the problem? (B) Where you put your error-handling is up to you. It depends on what the function does and how it is to respond. Do you want the function to t

Re: Catch exceptions

2006-02-27 Thread Cruella DeVille
I put the try catch in my main-method, and it worked to some extent (except from when I try to read from a file with no content) Any idea how to solve that? And is it a good place to have a try-except in main instead of in the class methods? My code is at http://nibbler.no/blog/wp-includes/Bookma

Re: Catch exceptions

2006-02-27 Thread Crutcher
Without seeing more of your code, I'm not sure what you are doing wrong. This works: ex.py vv def xopen(path): try: return open(path) except IOError, e: print 'Error:', e.args[1] xopen('xyzzy') ^^ $ python ex.py Error: No such file or direct

Catch exceptions

2006-02-27 Thread Cruella DeVille
In my application of bookmarks I get a filename as a parameter in one of my methods. I want to catch the "FileNotFoundException" if the user types an invalid filename. My code (that doesn't do what I want it to do - namely print a nicely formatted error message, and no stack trace) def openFile(se