How to handle errors from frappe/erpnext in android

Hi,

I am developing an android app and am using volley requests to send API requests to frappe/ERPNext. I have observed that Frappe returns a JSON type response on success and a html/text on error responses.

Android volley requests handle JSON responses well by default and for other types, I am forced to write a custom code to parse the error response and then display the appropriate one to the user. The last line in the html stack trace (that is sent as the response in case of an error) is the most appropriate error to be displayed in my opinion. Parsing each and every error response is very tedious and heavy on the application (the android app ) and is a disadvantage for the android developers in my opinion.

Does anyone know how to handle these error responses in a better way and if so, how ? or can Frappe/erpnext give a json response for errors as well?

I would ideally like to emulate the web interface of ERPNext/Frappe where the error is thrown as a message to the user in a dialog box.

Any pointers/opinions on the matter will help and is most welcome.

Thanks,
Pragnya

Hello Pragnya,
I am trying to do the same I need to parse JSON when it returns error on different HTTP Status code. Kindly please let me know if you were able to solve it?