How to handle REST service exceptions

We are consuming a REST service that returns a HTTP statuscode for the status of the request. In case of a functional error it can return statuscode 404. In that case the responsebody decribes the error in JSON format. The current version of the REST service module throws an exception for other statuscodes than 200 en 304. As a consequence I can the statuscode and responsebody are not available in the microflow that does the request. We would like to use the returning statuscode and responsebody so we can inform the user. Is there a way to make the statuscode and responsebody available?
1 answers

If I remember correctly, the error message now always starts with the response code (first 3 characters).

But I can see that it would be very convenient to have the result object also when the exception fails. You might notice that if you call the action from java and process the RestServiceException all data is actually in there. But to be able to do this in a microflow is nice as well.

Would an additional parameter on the 'request' java action for this suffice? Or maybe a 'surpressException' java action call before you perform the request to indicate that you want to handle the exception yourself?

UPDATE 5-6-2014

Just opened an issue for this on the github project:

The proposed solution is to call the getRestConsumeError function in your error handler, which returns the very same RequestResult object that would otherwise have been returned if the request had succeeded, but this time with ErrorCode set to error. You could then further parse the error message by invoke deserializeJsonToMendixObject on the ResponseBody property.

The patched module can be downloaded from here. Please let me know (either here or on GitHub) if the patch suffices, in that case I'll make sure it becomes part of the next release.