Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Misleading Exception handling in GraphDatabase.__init__() #65

Closed
doismellburning opened this Issue · 5 comments

2 participants

Kristian Glass Javier de la Rosa
Kristian Glass

At https://github.com/versae/neo4j-rest-client/blob/master/neo4jrestclient/client.py#L80 is the following code:

    try:
        response, content = Request(**self._auth).get(url)
    except Exception:
        raise NotFoundError(result="Unable get root")

When I changed that raise to raise NotFoundError(result="Unable get root (caused by: %s)" % e) I found that in fact, it was caused by a 401, which the NotFoundError obfuscates:

NotFoundError: Error [404]: Not Found. Nothing matches the given URI.
Unable get root (caused by: Error [401]: Unauthorized. No permission -- see authorization schemes.
Authorization Required)`

Now subsequent code handles response.status not being 200, so I'm not sure of what the except was expected to handle. I can see a number of ways of solving this; it is after all not much more than a cosmetic issue, but I'm not sure I see the best way to do so.

Javier de la Rosa
Owner

I see, maybe it's a better option there to use StatusException instead of NotFoundError. Please, try StatusException and tell me if it makes more sense:

    try:
        response, content = Request(**self._auth).get(url)
    except Exception:
        raise StatusException(result="Unable get root")
Javier de la Rosa versae was assigned
Kristian Glass

It already is a StatusException that's being raised though...

Javier de la Rosa
Owner

Ouch! You are right. Better removing the try except block and leaving just the

    response, content = Request(**self._auth).get(url)
Javier de la Rosa
Owner

Thanks!

Javier de la Rosa versae closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.