Skip to content
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

reaction to wrong server URL is unhelpful, makes the plugin unresponsive #60

Closed
tpo opened this issue Sep 30, 2022 · 2 comments
Closed

Comments

@tpo
Copy link
Contributor

tpo commented Sep 30, 2022

When I enter a wrong Server URL in the plugin:

image

I get a traceback window with this:

qgiscloud.qgiscloudapi.qgiscloudapi.BadRequestError
Traceback (most recent call last):
  File "/home/tpo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgiscloud/qgiscloudapi/qgiscloudapi.py", line 684, in request
    response = urllib.request.urlopen(req).read()
  File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tpo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgiscloud/qgiscloudplugindialog.py", line 334, in check_login
    login_info = self.api.check_login(
  File "/home/tpo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgiscloud/qgiscloudapi/qgiscloudapi.py", line 161, in check_login
    content = request.post(resource, data)
  File "/home/tpo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgiscloud/qgiscloudapi/qgiscloudapi.py", line 596, in post
    return self.request(resource, method='POST', data=data)
  File "/home/tpo/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgiscloud/qgiscloudapi/qgiscloudapi.py", line 698, in request
    raise BadRequestError(msg)
qgiscloud.qgiscloudapi.qgiscloudapi.BadRequestError


Python-Version: 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
QGIS-Version: 3.10.14-A Coruña A Coruña, exported

Python-Pfad:
/usr/share/qgis/python
/home/tpo/.local/share/QGIS/QGIS3/profiles/default/python
/home/tpo/.local/share/QGIS/QGIS3/profiles/default/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python39.zip
/usr/lib/python3.9
/usr/lib/python3.9/lib-dynload
/home/tpo/.local/lib/python3.9/site-packages
/usr/local/lib/python3.9/dist-packages
/usr/lib/python3/dist-packages
/usr/lib/python3.9/dist-packages
/home/tpo/.local/share/QGIS/QGIS3/profiles/default/python
/home/tpo/src/_qgis/adventsfenster-breite

There are a few problems with this:

  1. the reaction of the qgis-cloud-plugin is not really helpful. We're getting back a "HTTP Error 400: Bad Request" so the qgis-cloud-plugin could be guessing that the URL is probably wrong and tell the user so
  2. the error message does not mention the URL that results in the 400 error. So the user can only guess at which point in the communication step resp. protocol between the qgis-cloud-plugin client and the QGIS Cloud server the error happened.
  3. after this error the plugin becomes unresponsive. The user needs to restart QGIS. That's really cumbersome. See errors in the plugin render it unresponsive as a rule #61
  4. looking at the error handling at
    except urllib.error.HTTPError as e:
    I notice that the urllib.error.HTTPError exception instance gets replaced by custom exceptions thereby loosing all context such as the URL that caused the error. Which means that the callsite, that called Request.request will be unable to use the original context to form an intelligent response to the problem (as described in the first point above) (or by just displaying the faulty URL). I don't understand why this repackaging with context loss is being done in the exception handling - it seems rather strange to me it is done that way.
    This react
@mwa
Copy link
Member

mwa commented Mar 28, 2023

Better error handling for invalid API URLs is implemented in QGIS Cloud plugin v3.8.3

@mwa mwa closed this as completed Mar 28, 2023
@tpo
Copy link
Contributor Author

tpo commented Mar 28, 2023

Yeeee! Thank you @mwa !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants