All files / src/app/core/services error-processor.service.ts

90% Statements 9/10
100% Branches 2/2
75% Functions 3/4
100% Lines 4/4

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 17 18 19 20 21 2223x 23x                           23x     8x      
import { Injectable } from '@angular/core';
import { Observable, throwError } from 'rxjs';
 
 
/**
 * This service externalizes the throwError() call
 * Useful e.g. when components have to rethrow an error in a catchError() + subscribe() context
 * It improves testabiliy to use an external service instead of a direct throwError call
 * because errors contents may be tested by spying on the processError method
 * Otherwise, direct throwError calls cannot be checked as they are never passed to the GlobalErrorHandler while testing
 * 
 */
@Injectable({
  providedIn: 'root'
})
export class ErrorProcessorService {
 
  public processError(error: Error): Observable<never> {
    return throwError(() => error);
  }
}