diff --git a/frappe/public/js/frappe/request.js b/frappe/public/js/frappe/request.js index eff0391338..87309f4226 100644 --- a/frappe/public/js/frappe/request.js +++ b/frappe/public/js/frappe/request.js @@ -292,8 +292,15 @@ frappe.request.call = function(opts) { .fail(function(xhr, textStatus) { try { if (xhr.responseText) { - var data = JSON.parse(xhr.responseText); - if (data.exception) { + var data; + try { + data = JSON.parse(xhr.responseText); + } catch (e) { + console.log("Unable to parse reponse text"); + console.log(xhr.responseText); + console.log(e); + } + if (data && data.exception) { // frappe.exceptions.CustomError -> CustomError var exception = data.exception.split('.').at(-1); var exception_handler = exception_handlers[exception];