# All files / src/app/shared/services js-error-handler.service.ts

57.14% Statements 8/14
28.57% Branches 2/7
50% Functions 1/2
50% Lines 6/12

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
    174x
    4x

    4x
    22x

    4x

    4x
     import { ErrorHandler, Injectable, Injector } from '@angular/core';
    import { LoggingService } from '../api/logging.service';

    @Injectable()
    export class JsErrorHandler implements ErrorHandler {
      constructor(private injector: Injector) {}

      handleError(error) {
        const loggingService = this.injector.get(LoggingService);
        const url = window.location.href;
        const message = error && error.message;
        const stack = error && error.stack;
        loggingService.jsError(url, message, stack).subscribe();
        throw error;
      }
    }