From f24596eb8e768dbe8ff6df976ddc58badcc5cd79 Mon Sep 17 00:00:00 2001 From: Chneemann Date: Sat, 29 Mar 2025 16:39:09 +0100 Subject: [PATCH] refactor: Simplified error messages in ErrorNotificationService to enhance user experience --- .../services/error-notification.service.ts | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/app/services/error-notification.service.ts b/src/app/services/error-notification.service.ts index 90ea665..06d8a80 100755 --- a/src/app/services/error-notification.service.ts +++ b/src/app/services/error-notification.service.ts @@ -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, + }); } }