You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The response class BatchGetResponse has a field errors, although I'm not sure it really contains the errors because the last time I got an error this field was empty, but maybe I'm misremembering it.
Anyway, there are other response classes that have no error fields. For example, CollectionResponse has no errors field. So, if we get an error, we need to actually inspect the response attribute of the response object. So, we need to do something like this
Why does BatchGetResponse have an errors field but CollectionResponse doesn't?
Can we add an errors field to all responses and in particular CollectionResponse? I think this would be quite useful. In fact, without the error details, it becomes a bit hard to spot the mistakes/bugs. So, this errors field should be e.g. response.response.json(), if not response.response.ok, else be empty
The text was updated successfully, but these errors were encountered:
@nbro10 The reason BatchGetResponse has an errors field is because there can be errors returned for individual get calls. Like if you're doing batch_get of 10 items, and 2 of them fail, the errors field should be populated with two items, but the call as a whole will still succeed. Whether the API populates this errors field correctly is up to the service to implement correctly. If this isn't being populated, then that's a separate issue.
If something else is entirely wrong with the batch_get call, then it will return a non-2xx status code with the error object as the response payload.
For CollectionResponse, there isn't an errors field because the call either succeeds or fails. If there is an error, the status code will be non-2xx and the response payload will be the error object. The error object isn't completely standardized across all APIs afaik. Certain APIs have standardized the error format and provide the mapping of error codes.
@shimizust So, generally, if we want to check if there are any errors and the response is successful, we should check the HTTP response status code and not the errors field (if it exists). Is that what you suggest?
The response class
BatchGetResponse
has a fielderrors
, although I'm not sure it really contains the errors because the last time I got an error this field was empty, but maybe I'm misremembering it.Anyway, there are other response classes that have no error fields. For example,
CollectionResponse
has noerrors
field. So, if we get an error, we need to actually inspect theresponse
attribute of the response object. So, we need to do something like thisMy questions are:
BatchGetResponse
have anerrors
field butCollectionResponse
doesn't?CollectionResponse
? I think this would be quite useful. In fact, without the error details, it becomes a bit hard to spot the mistakes/bugs. So, thiserrors
field should be e.g.response.response.json()
, ifnot response.response.ok
, else be emptyThe text was updated successfully, but these errors were encountered: