If I'm retrieving JSON of a Wikidata item it's possible to use e.g.
https://www.wikidata.org/wiki/Special:EntityData/Q123.json
and get JSON back (which is great). But if there's an error, for example:
https://www.wikidata.org/wiki/Special:EntityData/Q123foo.json
then the response is HTML. Am I missing a request parameter or something, that would mean I get the error response in JSON as well?