Skip to content

Instantly share code, notes, and snippets.

@JohannesHoppe
Created June 8, 2019 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohannesHoppe/6c52f721c42f19b8c63cf563f5665a81 to your computer and use it in GitHub Desktop.
Save JohannesHoppe/6c52f721c42f19b8c63cf563f5665a81 to your computer and use it in GitHub Desktop.
Quick and dirty reaction to rxjs errors
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