Closed AaronDavidSchneider closed 2 years ago
Good idea, never thought about this usecase. But returning None
in case of failure may result in problems for the caller expecting something but None
. From my point of view it may be better to raise an error. As it is an error related to an action I suppose a FritzActionError
may be appropriate. So the code can look something like this (untested):
with self.fc.session.get(url) as response:
if not response.ok:
message = "Device has no access to topology information."
raise FritzActionError(message)
return response.text if raw else response.json()
May be it could also be a good idea to include the response status in the error message. What do you think?
I agree! Thanks for the review!
Repeaters do not have access to meshlist.lua. In the current implementation of fritzhosts we would therefore get a
JSONDecodeError
when usingget_mesh_topology
on a repeater.This PR catches the 404 error and returns None.