update error handler
This commit is contained in:
@@ -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 || 'خطای نامشخص رخ داده است';
|
||||
|
||||
Reference in New Issue
Block a user