mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 17:51:40 +09:00
Miscellaneous fixes to Rhymix.ajax() handling
This commit is contained in:
parent
213b354891
commit
2b62780b90
1 changed files with 4 additions and 7 deletions
|
|
@ -481,7 +481,6 @@ Rhymix.ajax = function(action, params, callback_success, callback_error) {
|
||||||
// Define the success wrapper.
|
// Define the success wrapper.
|
||||||
const successWrapper = function(data, textStatus, xhr) {
|
const successWrapper = function(data, textStatus, xhr) {
|
||||||
|
|
||||||
console.log(resolve);
|
|
||||||
// Add debug information.
|
// Add debug information.
|
||||||
if (data._rx_debug) {
|
if (data._rx_debug) {
|
||||||
data._rx_debug.page_title = "AJAX : " + action;
|
data._rx_debug.page_title = "AJAX : " + action;
|
||||||
|
|
@ -507,7 +506,6 @@ Rhymix.ajax = function(action, params, callback_success, callback_error) {
|
||||||
// This can be canceled by Rhymix.cancelPendingRedirect() within 100 milliseconds.
|
// This can be canceled by Rhymix.cancelPendingRedirect() within 100 milliseconds.
|
||||||
if (data.redirect_url) {
|
if (data.redirect_url) {
|
||||||
Rhymix.redirectToUrl(data.redirect_url.replace(/&/g, '&'), 100);
|
Rhymix.redirectToUrl(data.redirect_url.replace(/&/g, '&'), 100);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the promise with the response data.
|
// Resolve the promise with the response data.
|
||||||
|
|
@ -539,15 +537,13 @@ Rhymix.ajax = function(action, params, callback_success, callback_error) {
|
||||||
if (error_details.length > 1000) {
|
if (error_details.length > 1000) {
|
||||||
error_details = error_details.substring(0, 1000) + '...';
|
error_details = error_details.substring(0, 1000) + '...';
|
||||||
}
|
}
|
||||||
if (error_details.length > 0) {
|
|
||||||
error_message = error_message + "\n\n" + error_details;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reject the promise with an error object.
|
// Reject the promise with an error object.
|
||||||
// If uncaught, this will be handled by the 'unhandledrejection' event listener.
|
// If uncaught, this will be handled by the 'unhandledrejection' event listener.
|
||||||
const err = new Error(error_message);
|
const err = new Error(error_message);
|
||||||
err._rx_ajax_error = true;
|
err._rx_ajax_error = true;
|
||||||
err.cause = data;
|
err.cause = data;
|
||||||
|
err.details = error_details;
|
||||||
err.xhr = xhr;
|
err.xhr = xhr;
|
||||||
reject(err);
|
reject(err);
|
||||||
};
|
};
|
||||||
|
|
@ -1085,10 +1081,11 @@ window.addEventListener('unhandledrejection', function(event) {
|
||||||
if (event.reason && event.reason['_rx_ajax_error']) {
|
if (event.reason && event.reason['_rx_ajax_error']) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const error_message = event.reason.message.trim();
|
const error_message = event.reason.message.trim();
|
||||||
|
const error_details = event.reason.details || '';
|
||||||
const error_xhr = event.reason.xhr || {};
|
const error_xhr = event.reason.xhr || {};
|
||||||
console.error(error_message.replace(/\n+/g, "\n"));
|
console.error(error_message.replace(/\n+/g, "\n" + error_details));
|
||||||
if (Rhymix.showAjaxErrors.indexOf('ALL') >= 0 || Rhymix.showAjaxErrors.indexOf(error_xhr.status) >= 0) {
|
if (Rhymix.showAjaxErrors.indexOf('ALL') >= 0 || Rhymix.showAjaxErrors.indexOf(error_xhr.status) >= 0) {
|
||||||
alert(error_message.trim());
|
alert(error_message.trim() + (error_details ? ("\n\n" + error_details) : ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue