Skip to content

API Reference


API Reference / @dasch-ng/rxjs-operators / filterError

Function: filterError() ​

filterError(): (source$) => Observable<Error>

Defined in: filter-error.ts:23

Filters values to only allow Error instances, with proper TypeScript type narrowing.

This operator removes all non-Error values from the observable stream and narrows the type to Error, ensuring type safety in TypeScript. Useful for error handling and filtering error streams.

Returns ​

An operator function that filters to only Error instances

(source$) => Observable<Error>

Example ​

typescript
import { of } from 'rxjs';
import { filterError } from '@dasch-ng/rxjs-operators';

of(new Error('fail'), 'success', new TypeError('type error'), 42)
  .pipe(filterError())
  .subscribe(console.log);
// Output: Error('fail'), TypeError('type error')

Released under the MIT License.