openfisca / openfisca-web-api

[DEPRECATED] Web API for OpenFisca
https://www.openfisca.fr/
GNU Affero General Public License v3.0
13 stars 11 forks source link

Errors have to contain a `'code'` key #15

Closed MattiSG closed 9 years ago

MattiSG commented 9 years ago

An assumption is made in wsgihelpers.py that attributes 'error' in data contain a 'code' attribute:

code = code or error['code']

This makes the server crash with a 500 if it is not the case, with the following error:

TypeError: string indices must be integers, not str

The original error thus never reaches the end user.

It should at least be documented that error can not be a string. I can do it, but I don't know which Python type you are expecting here.