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

Python error Json decode #27

Open
pcav opened this issue Feb 3, 2016 · 4 comments
Open

Python error Json decode #27

pcav opened this issue Feb 3, 2016 · 4 comments
Assignees
Labels

Comments

@pcav
Copy link

pcav commented Feb 3, 2016

JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/home/paolo/.qgis2/python/plugins/qgisgbifapi/qgis_occurrences_dialog.py", line 167, in load_occurrences
count = count_occurrences(filters)
File "/home/paolo/.qgis2/python/plugins/qgisgbifapi/gbif_webservices.py", line 34, in count_occurrences
resp = req.json()
File "/usr/lib/python2.7/dist-packages/requests/models.py", line 808, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python2.7/dist-packages/simplejson/init.py", line 516, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Versione Python: 2.7.11 (default, Jan 11 2016, 21:04:40) [GCC 5.3.1 20160101]
Versione di QGIS: 2.13.0-Master Master, exported

@pcav
Copy link
Author

pcav commented Feb 3, 2016

Searching for Taxon key: mammalia in Country: Malaysia

@niconoe niconoe added the bug label Feb 3, 2016
@niconoe niconoe self-assigned this Feb 3, 2016
@niconoe
Copy link
Member

niconoe commented Feb 3, 2016

Thanks for your report!

According to the GBIF API Documentation (http://www.gbif.org/developer/occurrence), taxonKey should be an integer, not a taxon name. The API therefore returns Invalid integer range: mammalia, which makes the plugin crash.

I suggest:

  1. Fixing the plugin so it reports a proper error message instead of that traceback.
  2. Adding some info in the UI so the user know what to type in each filter (see Add "help" infobox for filters #15 )

What do you think?

@pcav
Copy link
Author

pcav commented Feb 3, 2016

IMHO:

  • the plugin should not crash
  • in case of error, the user should be presented some useful hint on what's wrong
  • the field should accept only type of data compatible with what the backend accepts
  • maybe for higher level taxa a dropdown list could be used
  • a suggestion (tooltip, ?, or similar) is always good
  • some documentation could be added, with an Help button.
    Thanks!

@niconoe
Copy link
Member

niconoe commented Feb 4, 2016

Thanks, all excellent suggestions!

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

No branches or pull requests

2 participants