rclient icon indicating copy to clipboard operation
rclient copied to clipboard

error parsing should be easier

Open zpatrick opened this issue 8 years ago • 0 comments

Right now, you need to totally override the request reader if you want to read custom error types. It should be more simple to try and marshal into errors. Perhaps a request option:

var resp int
var myerr *MyCustomError
client.Get("/path", &resp, rclient.Error(&myerr))

Another option could map status codes to types:

client.Get("/path", &resp, rclient.StatusMap(
    series.Ints(200, 299): &someType,
    series.Ints(400, 499): &someError,
    series.Ints(500, 599): &someOtherError,
))

zpatrick avatar Mar 22 '17 22:03 zpatrick