Bookworm-project / BookwormDB

Tools for text tokenization and encoding
MIT License
84 stars 12 forks source link

Successful html codes on failure #87

Open bmschmidt opened 8 years ago

bmschmidt commented 8 years ago

Note: this is just a copy of the issue filed by @organisciak at https://github.com/Bookworm-project/BookwormAPI/issues/16, because the problem lives here now.


When the BookwormAPI fails, it doesn't send an HTML error code for clients to interpret.

Since the most recent commit, I can't find any failed queries from BookwormGUI, so this is low priority, I suppose. Here's a simulated query with an error, which provides a 200 Status Code:

http://bookworm.htrc.illinois.edu/cgi-bin/dbbindings.py?query={%22groups%22:[%22date_year%22],%22counttype%22:%22WordsPerMillion%22,%22words_collation%22:%22Case_Sensitive%22,%22database%22:%22hathipd%22,%22search_limits%22:[{%22word%22:[%22\\\%22],%22date_year%22:{%22$gte%22:1750,%22$lte%22:1923}}],%22method%22:%22return_json%22}

bmschmidt commented 8 years ago

There are two different types of errors:

1) Something breaks in the code and it actually raises an error

2) The query breaks in a predictable way that can yield a blank response. For instance, if a searched-for word is not in the database, or if the user specifies a metadata field that doesn't exist. Rather than throwing a blanket 500 error, it would be nice to send a specific message like

{"error":"No bookworm database of that name is available on the server"}