ソースを参照

fix: catch exceptions while parsing json on request failure

version-14
Saqib Ansari 3年前
コミット
55178101e8
1個のファイルの変更9行の追加2行の削除
  1. +9
    -2
      frappe/public/js/frappe/request.js

+ 9
- 2
frappe/public/js/frappe/request.js ファイルの表示

@@ -292,8 +292,15 @@ frappe.request.call = function(opts) {
.fail(function(xhr, textStatus) { .fail(function(xhr, textStatus) {
try { try {
if (xhr.responseText) { 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 // frappe.exceptions.CustomError -> CustomError
var exception = data.exception.split('.').at(-1); var exception = data.exception.split('.').at(-1);
var exception_handler = exception_handlers[exception]; var exception_handler = exception_handlers[exception];


読み込み中…
キャンセル
保存