Open miclaus opened 8 years ago
Not quite what was expected ..
The District Results by id web service now always retrieves an error object, which should not be, since the district is found.
Example: /bpw16b/w/1
{
errors: {
status: 420,
title: "'1' not found",
detail: "Sorry! We could not find a district with the id '1'."
}
district: { ... },
state: { ... },
election: { ... }
}
Also if the districtId
is set to results
like so: /bpw16b/w/results
, then instead of retrieving a single error object (since results
is not a valid districtId
), the following response is retrieved:
{
errors: {
status: 420,
title: "'results' not found",
detail: "Sorry! We could not find a district with the id 'results'."
},
state: { ... }
election: { ... }
}
It could be argued for, that if there isn't a valid districtId
given, at least the state
and election
results objects should be retrieved besides an error object. However I don't see how an app could integrate this positively.
Was this intended @suits-at, or simply not tested yet?
Furthermore there are some calls, which return Laravel specific error messages and haven't been take into account.
Examples / Todos:
/bpw16b/w/1
/bpw16b/w/results
/bpw16b/results/1
/bpw16b/w/1/donut-chart
/bpw16b/results/results
/bpw16b/INVALID/results
Therefore I reopened the issue.
In case of errors, the web services should respond w/ JSON error object.
Something in the format of http://jsonapi.org/examples/#error-objects would be nice.
Example:
( I guess
source
is not necesarry in our case, since a simple error message suffices. )