Pārlūkot izejas kodu

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

fix: catch exceptions while parsing json on request failure
version-14
mergify[bot] pirms 3 gadiem
committed by GitHub
vecāks
revīzija
85fc42a1ea
Šim parakstam datu bāzē netika atrasta zināma atslēga GPG atslēgas ID: 4AEE18F83AFDEB23
1 mainītis faili ar 12 papildinājumiem un 5 dzēšanām
  1. +12
    -5
      frappe/public/js/frappe/request.js

+ 12
- 5
frappe/public/js/frappe/request.js Parādīt failu

@@ -291,11 +291,18 @@ frappe.request.call = function(opts) {
})
.fail(function(xhr, textStatus) {
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];
if (exception_handler) {
exception_handler(data);


Notiek ielāde…
Atcelt
Saglabāt