Failed API Response

Hi, I am using API to read, write and update documents, On success its returns proper JSON, however when ever there is an error/exception it doesn’t return JSON output instead the output contains:

Status: 417 Expection failed
format: HTML page with server error box, containing python based error as shown in attached pic as well.

So is there any way to retrieve the end error in JSON output?


I am using API from external app not on frappe.


you will have to manually throw implement JSON errors from your whitelisted functions.

    frappe.local.response = frappe._dict(out)  # pylint: disable=assigning-non-slot

where out is the response you wish to sent from your whitelised function