Can't get the response body if validation fails
zwolsman opened this issue · comments
If the validation fails (let's say the server returns 400> status code) there is no way to get the data that the server returns.
Would be very helpful if there is a way to get the data so you can display server sided exceptions.
@zwolsman Hi, Malibu
deals with Promise
, so you can use fail
to catch error
.done({ boards in
// Handle response data
})
.fail({ error in
// Handle errors
})
.always({ _ in
// Hide progress bar
})
I saw that, but the problem is. if you have code like this
.validate(statusCodes: [200]).fail({err in print(err) })
The err
will be Response status code \(statusCode) was unacceptable
, you are not able to get the response body from the request..
@zwolsman Would it solve your problem if we extend error types with more parameters, like:
case unacceptableStatusCode(Int, Data, HTTPURLResponse)
case unacceptableContentType(String, Data, HTTPURLResponse)
@vadymmarkov I think that every error that throws (and there is data available) it should contain the data. Maybe a transformer too so you can map your data to your error object.
I agree, we can start with errors. I will look into it 😉
Version 6.1.0 with improved errors is out @zwolsman