瀏覽代碼

Merge pull request #15549 from nextchamp-saqib/handle-504-errors

fix: catch exceptions while parsing json on request failure
version-14
mergify[bot] 3 年之前
committed by GitHub
父節點
當前提交
85fc42a1ea
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 12 行新增5 行删除
  1. +12
    -5
      frappe/public/js/frappe/request.js

+ 12
- 5
frappe/public/js/frappe/request.js 查看文件

@@ -291,11 +291,18 @@ frappe.request.call = function(opts) {
}) })
.fail(function(xhr, textStatus) { .fail(function(xhr, textStatus) {
try { try {
if (xhr.responseText) {
var data = JSON.parse(xhr.responseText);
if (data.exception) {
// frappe.exceptions.CustomError -> CustomError
var exception = data.exception.split('.').at(-1);
if (xhr.getResponseHeader('content-type') == 'application/json' && xhr.responseText) {
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: (1024, ...) -> CustomError
var exception = data.exception.split('.').at(-1).split(':').at(0);
var exception_handler = exception_handlers[exception]; var exception_handler = exception_handlers[exception];
if (exception_handler) { if (exception_handler) {
exception_handler(data); exception_handler(data);


Loading…
取消
儲存