You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ python x.py
Traceback (most recent call last):
File "x.py", line 8, in <module>
connection = Connection('http://httpbin.org/')
File "[...]/huawei_lte_api/Connection.py", line 45, in __init__
self._initialize_csrf_tokens_and_session()
[...]
xml.parsers.expat.ExpatError: syntax error: line 1, column 54
Should provide a more indicative error than a generic XML parse one. Preferably something that the user code can examine to determine that the server is not a Huawei LTE device (e.g. somehow the 404 passed through). Perhaps should not try parsing XML for 404's, use requests' raise_for_error selectively (or everywhere except selectively not) etc.
The text was updated successfully, but these errors were encountered:
There is no 100% way to check if device we are trying to connect is a Huawei LTE modem (except checking MAC but that is BS)...
So i think best way will be to handle that XML parse exception and "rethrow" our own IDK something like:
raiseResponseParseException('Failed to parse XML response from device, are you sure that {host} is a supported Huawei LTE Modem?'.format(host=host))
As mentioned, I think the HTTP status code should be a part of the exception thrown there, so users can use that in their decision making. Possibly also some other sanity checks on the structure we get if the XML parses successfully, if doable.
In case, let's chain the original exception if there is one, like raise OurException(..., htttp_status=...) from originalexception
Should provide a more indicative error than a generic XML parse one. Preferably something that the user code can examine to determine that the server is not a Huawei LTE device (e.g. somehow the 404 passed through). Perhaps should not try parsing XML for 404's, use requests' raise_for_error selectively (or everywhere except selectively not) etc.
The text was updated successfully, but these errors were encountered: