Skip to content
Snippets Groups Projects
error.service.ts 774 B
Newer Older
jojohoch's avatar
jojohoch committed
import { ErrorHandler, Injectable } from '@angular/core';
import { VeronaPostService } from 'player/modules/verona/services/verona-post.service';
import { AspectError } from 'common/classes/aspect-error';

@Injectable({
  providedIn: 'root'
})
export class ErrorService implements ErrorHandler {
  constructor(private veronaPostService: VeronaPostService) {}

  handleError(error: AspectError): void {
    if (error.name === AspectError.name) {
      this.veronaPostService.sendVopRuntimeErrorNotification(error);
    } else {
      this.veronaPostService.sendVopRuntimeErrorNotification({ code: 'runtime-error', message: error.message });
      // eslint-disable-next-line no-console
    // eslint-disable-next-line no-console
    console.error(error.message);