Created
June 8, 2019 05:14
-
-
Save JohannesHoppe/6c52f721c42f19b8c63cf563f5665a81 to your computer and use it in GitHub Desktop.
Quick and dirty reaction to rxjs errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { OperatorFunction, EMPTY } from 'rxjs'; | |
import { catchError } from 'rxjs/operators'; | |
import { ErrorDisplayService } from './error-display.service'; | |
export function swallowError<T>(): OperatorFunction<T, T> { | |
return catchError(() => (EMPTY)); | |
} | |
export function swallowErrorWithDisplay<T>(eds: ErrorDisplayService): OperatorFunction<T, T> { | |
return catchError(err => { | |
eds.reportError(err); | |
return EMPTY; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment