# Function: catchErrorSource()

> **catchErrorSource**\<`Payload`, `TypePrefix`\>(`typePrefix`): (`source$`) => `Observable`\<`Payload` \| [`Action`](../../../state-adapt-core/references/src/Action.md)\<`any`, `` `${TypePrefix}.error$` ``\>\>

`catchErrorSource` is a custom RxJS [operator](https://rxjs.dev/guide/operators) that converts an RxJS [Observable](https://rxjs.dev/guide/observable)
of any values into a source of errors, using RxJS' [catchError](https://rxjs.dev/api/operators/catchError) operator.
It takes one argument, TypePrefix, and prefixes it to create an object of type [Action](../../../state-adapt-core/references/src/Action.md)<any, ${TypePrefix}.error$>.

#### Example: Catching errors from a source

```typescript
import { timer, map } from 'rxjs';

const timer$ = timer(1000).pipe(
  map(n => ({ type: 'timer$', payload: n.fakeNumberMethod() })),
  catchErrorSource('timer'),
);

timer$.subscribe(console.log);
// { type: 'timer.error$', payload: 'Error: n.fakeNumberMethod is not a function' }
```
