mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-05 01:52:17 +09:00
Always stop after calling the error callback function, regardless of whether it returns false
This commit is contained in:
parent
dfdb3386d6
commit
cea2370520
1 changed files with 11 additions and 10 deletions
|
|
@ -523,13 +523,17 @@ Rhymix.ajax = function(action, params, callback_success, callback_error) {
|
||||||
// Define the error wrapper.
|
// Define the error wrapper.
|
||||||
const errorWrapper = function(data, textStatus, xhr) {
|
const errorWrapper = function(data, textStatus, xhr) {
|
||||||
|
|
||||||
// If an error callback is defined, and if it returns false, stop processing this error.
|
// If an error callback is defined, call it.
|
||||||
// This will also cause the promise to be rejected, but silently.
|
// The promise will still be rejected, but silently.
|
||||||
if (typeof callback_error === 'function' && callback_error(data, xhr) === false) {
|
if (typeof callback_error === 'function') {
|
||||||
promise.catch(function(dummy_err) { });
|
callback_error(data, xhr);
|
||||||
let dummy_err = new Error('AJAX error handled by callback function');
|
promise.catch(function(dummy) { });
|
||||||
dummy_err._rx_ajax_error = false;
|
let dummy = new Error('Rhymix.ajax() error already handled by callback function');
|
||||||
reject(dummy_err);
|
dummy._rx_ajax_error = true;
|
||||||
|
dummy.cause = data;
|
||||||
|
dummy.details = '';
|
||||||
|
dummy.xhr = xhr;
|
||||||
|
reject(dummy);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1092,9 +1096,6 @@ window.addEventListener('beforeunload', function() {
|
||||||
window.addEventListener('unhandledrejection', function(event) {
|
window.addEventListener('unhandledrejection', function(event) {
|
||||||
if (event.reason && typeof event.reason['_rx_ajax_error'] === 'boolean') {
|
if (event.reason && typeof event.reason['_rx_ajax_error'] === 'boolean') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (event.reason['_rx_ajax_error'] === false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const error_message = event.reason.message.trim();
|
const error_message = event.reason.message.trim();
|
||||||
const error_details = event.reason.details || '';
|
const error_details = event.reason.details || '';
|
||||||
const error_xhr = event.reason.xhr || {};
|
const error_xhr = event.reason.xhr || {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue