Handling multiple error messages returned (Rails style)

35 views
Skip to first unread message

Nic Werner

unread,
Jun 2, 2012, 6:33:39 PM6/2/12
to res...@googlegroups.com
I've seen the examples for mapping explicit error keyvalues, but it seems very brittle to try and map every keyvalue error that I could potentially get back. Is there a way to set the root of an error response, and then everything under that gets mapped into an Dictionary?

Example: I have a registration form that has a few conditions to be satisfied on the database end. I need to be able to get those unique responses, parse them and error appropriately.

This is the response back from a POST: {"error":{"category_id":["can't be blank"],"name":["has already been taken"]}}

How would I tell RestKit to take everything after "error" and put it into a dictionary?  With the object as the key, and the explicit error message as the value? Ex: "category_id" => "can't be blank" ? These aren't showing up in [error userInfo] as I would expect.

Thanks,
Nic.
Reply all
Reply to author
Forward
0 new messages