-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BadRequestError, UnauthorizedError, NotFoundError, etc. not raised #7
Comments
That is strange. Users shouldn't see aiohttp exceptions. These should be captured by the edit: lol, sorry for the ping :( |
In fact, there is a test for that. https://github.com/metricq/aiocouch/blob/master/tests/test_document.py#L51 At least for missing documents, you seem to have an authorization problem though. There's no check for that |
Okay, so I think what is happening for you is that your credentials aren't working. So no matter the request, you'll get a 401 status code. I added a check at the |
|
It didn't work, because I accidentally put the check in the wrong place. Can you try the current master again?
I'm not too convinced of that, in the end, making sure the provided credentials are valid is a normal part of communication with a server. Granted, usually, you'd have the server decline you during the connection process. Let us put that aside. I still think your credentials aren't valid. Because the |
Hey @bmario, thanks for following this up. I confirm that with latest master (f1abf39), I now get a proper
|
You raised fair points, so I removed the credentials check and wrapped those implicit status codes. One can still explicitly check the provided credentials using One remark, when Couchdb returns a 401 status code, I don't see an elegant solution to check whether there is a problem with the authentication, i.e., the provided credentials are valid, or with the authorization, e.g., administrator permissions required for the Anyways, can you try the latest commit once more and report back if my changes solved your issue? |
Thanks! I just tested and it works fine 👍
I totally agree, in my opinion that's why the difference between |
I'm closing this issue then. |
I'm opening an issue, I hope it's the right way to discuss on this. If the problem is known and not implemented yet, I'll be happy to help and/or contribute.
aiocouch defines various exception types (
NotFoundError
,UnauthorizedError
, etc.) but doesn't raise them upon HTTP errors. Instead, rawaiohttp.client_exceptions.ClientResponseError
exceptions are returned to the caller.As a result, it is not possible to easily handle error cases, like this:
Instead, I need to write this cumbersome code:
As a comparison, with https://github.com/djc/couchdb-python one could use:
The text was updated successfully, but these errors were encountered: