Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1x 1x 1x 1x | import { ErrorHandler, Injectable, inject } from '@angular/core';
import { LogService } from 'src/app/log/log.service';
@Injectable()
export class CustomErrorHandler implements ErrorHandler {
private readonly logService = inject(LogService);
public handleError(error?: unknown): void {
if (error === undefined) {
this.logService.sendErrorLog(
`undefined error: no error message specified`
);
return;
}
const description = error instanceof Error
? error.toString()
: typeof error === 'string' ? error : JSON.stringify(error);
this.logService.sendErrorLog(`${description} - ${JSON.stringify(error)}`);
console.error(error);
}
}
|