Open Source Web Application Framework for ASP.NET Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
1.2 KiB

import { CustomHttpErrorHandlerService } from '../models';
import {
CUSTOM_HTTP_ERROR_HANDLER_PRIORITY,
DEFAULT_ERROR_LOCALIZATIONS,
DEFAULT_ERROR_MESSAGES,
} from '../constants/error';
import { inject, Injectable } from '@angular/core';
import { CreateErrorComponentService } from './create-error-component.service';
@Injectable({ providedIn: 'root' })
export class UnknownStatusCodeErrorHandlerService implements CustomHttpErrorHandlerService {
priority = CUSTOM_HTTP_ERROR_HANDLER_PRIORITY.normal;
private statusText = 'Unknown Error';
private message = '';
private createErrorComponentService = inject(CreateErrorComponentService);
canHandle(error: { status: number; statusText: string; message: string } | undefined): boolean {
if (error && error.status === 0 && error.statusText === this.statusText) {
this.message = error.message;
return true;
}
return false;
}
execute() {
this.createErrorComponentService.execute({
title: {
key: DEFAULT_ERROR_LOCALIZATIONS.defaultError.title,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError.title,
},
details: this.message,
isHomeShow: false,
});
}
}