refactor: Simplified error messages in ErrorNotificationService to enhance user experience
This commit is contained in:
parent
839df9e3ff
commit
f24596eb8e
1 changed files with 20 additions and 10 deletions
|
|
@ -15,36 +15,46 @@ export class ErrorNotificationService {
|
|||
switch (error.status) {
|
||||
case 0:
|
||||
errorMessage =
|
||||
'Network issue: Unable to reach the server. Please check your internet connection or the server status.';
|
||||
'Unable to connect to the server. Please check your internet connection or the server status.';
|
||||
break;
|
||||
case 400:
|
||||
errorMessage =
|
||||
'The request could not be processed due to invalid input. Please check your entries and try again.';
|
||||
break;
|
||||
case 401:
|
||||
errorMessage =
|
||||
'Invalid login credentials. Please check your email and password.';
|
||||
'The login credentials are incorrect. Please check your email and password.';
|
||||
break;
|
||||
case 403:
|
||||
errorMessage = 'You do not have permission to access this resource.';
|
||||
errorMessage =
|
||||
'You do not have permission to access this resource. If you believe this is a mistake, please contact support.';
|
||||
break;
|
||||
case 404:
|
||||
errorMessage = 'The requested resource was not found.';
|
||||
break;
|
||||
case 500:
|
||||
errorMessage =
|
||||
'Server error: Please try again later. If the issue persists, please contact support.';
|
||||
'The requested page could not be found. Please make sure the URL is correct and try again.';
|
||||
break;
|
||||
case 408:
|
||||
errorMessage =
|
||||
'Request timed out. Please check your connection and try again.';
|
||||
'The request timed out. Please check your connection and try again later.';
|
||||
break;
|
||||
case 500:
|
||||
errorMessage =
|
||||
'There was a problem on the server. Please try again later or contact support if the issue persists.';
|
||||
break;
|
||||
default:
|
||||
errorMessage =
|
||||
error.error?.message ||
|
||||
`Unknown error: ${error.statusText || error.message}`;
|
||||
`An unknown error occurred. Please try again later.`;
|
||||
break;
|
||||
}
|
||||
} else if (error instanceof Error) {
|
||||
errorMessage = `Network error: ${error.message || error.toString()}`;
|
||||
}
|
||||
|
||||
this.toastr.error(errorMessage, 'Error');
|
||||
this.toastr.error(errorMessage, 'Error', {
|
||||
timeOut: 3000,
|
||||
positionClass: 'toast-top-right',
|
||||
progressBar: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue