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:
parent
ba2bbe7ca2
commit
41f8ed6f45
1 changed files with 4 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue