0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-15 03:01:37 -05:00

Improved error message when fetching resources fails (#20317)

ref
https://linear.app/tryghost/issue/SLO-118/[admin]-error-cannot-fetch-x
This commit is contained in:
Sag 2024-06-04 09:39:59 +02:00 committed by GitHub
parent ba2bbe7ca2
commit 41f8ed6f45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,10 +22,10 @@ export class APIError extends Error {
errorOptions?: ErrorOptions
) {
if (!message && response && response.url.includes('/ghost/api/admin/')) {
message = `${response.statusText}, cannot fetch ${response.url.replace(/.+\/ghost\/api\/admin\//, '').replace(/\W.*/, '').replace('_', ' ')}`;
message = `Something went wrong while loading ${response.url.replace(/.+\/ghost\/api\/admin\//, '').replace(/\W.*/, '').replace('_', ' ')}, please try again.`;
}
super(message || 'Unknown error', errorOptions);
super(message || 'Something went wrong, please try again.', errorOptions);
}
}
@ -48,13 +48,13 @@ export class VersionMismatchError extends JSONError {
export class ServerUnreachableError extends APIError {
constructor(errorOptions?: ErrorOptions) {
super(undefined, undefined, 'Server was unreachable', errorOptions);
super(undefined, undefined, 'Something went wrong, please try again.', errorOptions);
}
}
export class TimeoutError extends APIError {
constructor(errorOptions?: ErrorOptions) {
super(undefined, undefined, 'Request timed out', errorOptions);
super(undefined, undefined, 'Request timed out, please try again.', errorOptions);
}
}