BelgianBiodiversityPlatform / qgis-gbif-api

GBIF Occurrences is a QGIS plugin to directly import occurrences from the GBIF API
BSD 3-Clause "New" or "Revised" License
13 stars 5 forks source link

Python error Json decode #27

Open pcav opened 8 years ago

pcav commented 8 years ago

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 commented 8 years ago

Searching for Taxon key: mammalia in Country: Malaysia

niconoe commented 8 years ago

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 #15 )

What do you think?

pcav commented 8 years ago

IMHO:

niconoe commented 8 years ago

Thanks, all excellent suggestions!