-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror-handler.ts
More file actions
26 lines (23 loc) · 856 Bytes
/
error-handler.ts
File metadata and controls
26 lines (23 loc) · 856 Bytes
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
26
import { ErrorHandler, Injectable, NgZone } from '@angular/core';
import { hub } from '@logtide/core';
/**
* Angular ErrorHandler that reports uncaught errors to LogTide.
*
* Detects whether the error occurred inside or outside NgZone and tags
* the error accordingly. Errors outside NgZone often indicate issues with
* third-party libraries or manual DOM manipulation.
*
* Used automatically when you call `provideLogtide()` or import `LogtideModule`.
*/
@Injectable()
export class LogtideErrorHandler implements ErrorHandler {
handleError(error: unknown): void {
const zoneContext = NgZone.isInAngularZone() ? 'inside' : 'outside';
hub.captureError(error, {
mechanism: 'angular.errorHandler',
'angular.zone': zoneContext,
});
// Also log to console so errors remain visible in dev
console.error(error);
}
}