wapi-python icon indicating copy to clipboard operation
wapi-python copied to clipboard

Add 'Raises' section to docstring

Open gbm opened this issue 5 years ago • 3 comments

https://github.com/wattsight/wapi-python/blob/dc0d3534b4c8fe0bcc577ac25d93ebeffdfd2dc0/wapi/session.py#L115

I might have the expectation from the documentation that I will get a curve or None - in fact I get an exception if the curve is not found.

gbm avatar Jan 05 '21 16:01 gbm

https://github.com/wattsight/wapi-python/blob/dc0d3534b4c8fe0bcc577ac25d93ebeffdfd2dc0/wapi/session.py#L470

Any response from the API that does not return the HTTP code OK 200 will throw an exception. The API returns 404 when a curve is missing, an instance is missing etc. The API returns the appropriate HTTP error code where this makes sense. 403/401 for various authorization/authentication issues. We can also return other 4xx errors when your request exceeds limits or is otherwise malformed. 500 is returned when something has gone wrong in the API.

Returning None would not give you the error message or opportunity to handle the error correctly, which is why we throw the error(s).

rune-bk avatar Jan 06 '21 07:01 rune-bk

I think perhaps that not finding a curve is not an "exceptional event" and is in fact normal operation. However I understand your desire to communicate the error condition to the user - however none of what you have explained above is documented anywhere. Which is the point of this issue :)

gbm avatar Jan 06 '21 08:01 gbm

We are indeed lacking some cases around exception handling.

I will look into it for the upcoming release. We plan to add type hints to the upcoming release to ease these bits. It should be solved as a part of that process.

rune-bk avatar Jan 06 '21 15:01 rune-bk