PecanProject / bety

Web-interface to the Biofuel Ecophysiological Traits and Yields Database (used by PEcAn and TERRA REF)
https://www.betydb.org
BSD 3-Clause "New" or "Revised" License
16 stars 38 forks source link

Need "nicer" error handling when beta API data requests have a bad query string #461

Closed gsrohde closed 7 years ago

gsrohde commented 8 years ago

We can search for hybrid species by searching on the cross symbol (×) with the query https://www.betydb.org/api/beta/species?key=&scientificname=~%C3%97. But suppose the user mistakenly writes %3C%97 instead of %C3%97 for the URL encoding of the cross symbol. The query then becomes https://www.betydb.org/api/beta/species?key=&scientificname=~%3C%97. This query will respond with the (HTML) "We're sorry, but something went wrong" page on account of an exception triggered by the encoding error (PG::CharacterNotInRepertoire: ERROR: invalid byte sequence for encoding "UTF8").

The response should be in JSON format and should give clear information as to the nature of the error. (Similarly when requesting results in XML format.)

gsrohde commented 7 years ago

Fixed by release 4.14.