update error handler

This commit is contained in:
2026-04-06 18:33:17 +03:30
parent de1a046485
commit b3fb4f4baf
11 changed files with 129 additions and 24 deletions
+17 -13
View File
@@ -140,19 +140,23 @@ export class ErrorHandlerService {
* Extract user-friendly message from error
*/
private getUserMessage(error: HttpErrorResponse): string {
if (error.error && typeof error.error === 'object') {
// Try different common message fields
return (
error.error.message ||
error.error.error ||
error.error.detail ||
error.statusText ||
'خطای نامشخص رخ داده است'
);
}
if (typeof error.error === 'string') {
return error.error;
if (error.error) {
if (error.error.errors && Array.isArray(error.error.errors)) {
return error.error.errors[0];
}
if (typeof error.error === 'object') {
// Try different common message fields
return (
error.error.message ||
error.error.error ||
error.error.detail ||
error.statusText ||
'خطای نامشخص رخ داده است'
);
}
if (typeof error.error === 'string') {
return error.error;
}
}
return error.statusText || 'خطای نامشخص رخ داده است';