1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-13 23:13:36 +00:00
Files
browser/libs/angular/src/platform/services/logging-error-handler.ts
Matt Gibson b4631b0dd1 Ps/improve-log-service (#8989)
* Match console method signatures in logService abstraction

* Add a few usages of improved signature

* Remove reality check test

* Improve electron logging
2024-04-30 12:58:16 -04:00

23 lines
689 B
TypeScript

import { ErrorHandler, Injectable, Injector, inject } from "@angular/core";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
@Injectable()
export class LoggingErrorHandler extends ErrorHandler {
/**
* When injecting services into an `ErrorHandler`, we must use the `Injector` manually to avoid circular dependency errors.
*
* https://stackoverflow.com/a/57115053
*/
private injector = inject(Injector);
override handleError(error: any): void {
try {
const logService = this.injector.get(LogService, null);
logService.error("Unhandled error in angular", error);
} catch {
super.handleError(error);
}
}
}