Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 1.69 KB

File metadata and controls

46 lines (34 loc) · 1.69 KB

API > Interfaces

AppErrorEvent

Description

An interface that is used when tracking application errors.

Properties

Property Desciption
error: Error The error object being thrown.
id: string optional
A useful identifier for the event.
scopes?: [] optional
A list of scopes to include with the event.

Example

In this example an AppErrorEvent is being tracked via a custom error handler. The event is then fed to the trackAppError method on the EventDispatchService. The objects in scopes are completely customizable and determined by consuming applications.

import { AppErrorEvent, EventDispatchService } from 'oculr-ngx';

@Injectable()
export class AppErrorHandler implements ErrorHandler {
  constructor(private eventDispatchService: EventDispatchService) {}

  handleError(error: AppError | HttpErrorResponse): void {
    const event: AppErrorEvent = {
      error,
      id: error instanceof AppError ? error.name : error.status?.toString(),
      scopes: [
        {
          // the following property is only an example
          level: 'application',
        },
      ],
    };
    this.eventDispatchService.trackAppError(event);
  }
}

Feedback

Is something not working or unclear? Please create an issue or PR.