mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
Added 504 error handling in the admin (#18703)
refs https://github.com/TryGhost/Product/issues/4040 Added error handling for 504 errors to improve the message shown to the user when a 504 occurs
This commit is contained in:
parent
094ea1d2b0
commit
88e49b4f0e
@ -178,6 +178,22 @@ export function isEmailError(errorOrStatus, payload) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Gateway timeout error */
|
||||
|
||||
export class GatewayTimeoutError extends AjaxError {
|
||||
constructor(payload) {
|
||||
super(payload, 'Server is currently unavailable, please wait a moment then retry.', 504);
|
||||
}
|
||||
}
|
||||
|
||||
export function isGatewayTimeoutError(errorOrStatus) {
|
||||
if (isAjaxError(errorOrStatus)) {
|
||||
return errorOrStatus instanceof GatewayTimeoutError;
|
||||
} else {
|
||||
return errorOrStatus === 504;
|
||||
}
|
||||
}
|
||||
|
||||
/* end: custom error types */
|
||||
|
||||
export class AcceptedResponse {
|
||||
@ -326,6 +342,8 @@ class ajaxService extends AjaxService {
|
||||
return new EmailError(payload);
|
||||
} else if (this.isAcceptedResponse(status)) {
|
||||
return new AcceptedResponse(payload);
|
||||
} else if (this.isGatewayTimeoutError(status)) {
|
||||
return new GatewayTimeoutError(payload);
|
||||
}
|
||||
|
||||
let isGhostRequest = GHOST_REQUEST.test(request.url);
|
||||
@ -404,6 +422,10 @@ class ajaxService extends AjaxService {
|
||||
return isEmailError(status, payload);
|
||||
}
|
||||
|
||||
isGatewayTimeoutError(status) {
|
||||
return isGatewayTimeoutError(status);
|
||||
}
|
||||
|
||||
isAcceptedResponse(status) {
|
||||
return isAcceptedResponse(status);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ describe('Acceptance: Error Handling', function () {
|
||||
|
||||
expect(findAll('.gh-alert').length).to.equal(1);
|
||||
expect(find('.gh-alert').textContent).to.not.match(/html>/);
|
||||
expect(find('.gh-alert').textContent).to.match(/Request was rejected due to server error/);
|
||||
expect(find('.gh-alert').textContent).to.match(/Server is currently unavailable, please wait a moment then retry./);
|
||||
});
|
||||
|
||||
it('handles ember-ajax HTML response', async function () {
|
||||
@ -118,7 +118,7 @@ describe('Acceptance: Error Handling', function () {
|
||||
|
||||
expect(findAll('.gh-alert').length).to.equal(1);
|
||||
expect(find('.gh-alert').textContent).to.not.match(/html>/);
|
||||
expect(find('.gh-alert').textContent).to.match(/Request was rejected due to server error/);
|
||||
expect(find('.gh-alert').textContent).to.match(/Server is currently unavailable, please wait a moment then retry./);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user