reworking parse_response #55
tofuSCHNITZEL
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi,
when implementing set_clock and wanting to check if it was successful I looked at parse_response and noticed the following:
if an action like "common/notify_date_time" only returns "ret=OK" when it was successful or "ret=PARAM NG" in case there was e.g. a wrong parameter sent, the response that is returned from parse_response is in both cases just {}
so there is no way to distinguish between a call that was "OK" or that had an error. it does not matter in most cases because the response is often just given to "values.update" which in turn would just update nothing if ret is not "OK" but actually parse_response could raise an exception that is not handled in most of the cases (e.g. the self.values.update(await self._get_resource(path, params)) calls)
because I would suggest to raise an exception if ret != OK instead of just "silently" return nothing... but this would probably mean handling exception in more places...
What do you think about that?
All reactions