feat(core): act.operator - pass metadata and error.data to default error event
MODIFY
packages/core/src/operators/act/act.operator.spec.ts
packages/core/src/operators/act/act.operator.spec.ts
@@ -2,6 +2,7 @@ import { Observable, of, concat } from 'rxjs';
import { filter, tap, mergeMap } from 'rxjs/operators';
import { Event } from '../../event/event.interface';
import { Marbles } from '../../+internal/testing';
+import { ExtendableError } from '../../+internal/utils';
import { act } from './act.operator';
describe('#act operator', () => {
@@ -73,17 +74,18 @@ describe('#act operator', () => {
test('catches errored event => maps to default => continues stream', () => {
// given
- const event1: Event = { type: 'TEST_EVENT_1', payload: 1 };
- const event2: Event = { type: 'TEST_EVENT_2', payload: 2 };
- const event3: Event = { type: 'TEST_EVENT_3', payload: 3 };
- const event4: Event = { type: 'TEST_EVENT_4', payload: 4 };
- const eventErrored: Event = { type: 'TEST_EVENT_2', error: { name: 'Error', message: 'something went wrong' } };
+ const error = { name: 'TestError', message: 'TestErrorMessage' };
+ const event1: Event = { type: 'TEST_EVENT_1', payload: 1, metadata: { replyTo: 'channel_1' } };
+ const event2: Event = { type: 'TEST_EVENT_2', payload: 2, metadata: { replyTo: 'channel_2' } };
+ const event3: Event = { type: 'TEST_EVENT_3', payload: 3, metadata: { replyTo: 'channel_3' } };
+ const event4: Event = { type: 'TEST_EVENT_4', payload: 4, metadata: { replyTo: 'channel_4' } };
+ const eventErrored: Event = { type: 'TEST_EVENT_2', error, metadata: { replyTo: 'channel_2' } };
// when
const effect$ = (event$: Observable<Event>) =>
event$.pipe(
act((event: any) => of(event).pipe(
- tap(e => { if (e.payload === 2) throw new Error('something went wrong') }),
+ tap(e => { if (e.payload === 2) throw new ExtendableError(error.name, error.message) }),
)),
);

MODIFY
packages/core/src/operators/act/act.operator.ts
packages/core/src/operators/act/act.operator.ts
@@ -29,9 +29,10 @@ export function act<
errorFn?: (error: any, event: InputEvent) => ErrorEvent | Observable<ErrorEvent>,
) {
- const getDefaultErrorEvent = (error: Error) => (event: Event) => of({
+ const getDefaultErrorEvent = (error: any) => (event: Event) => of({
type: event.type,
- error: { name: error.name, message: error.message },
+ error: { name: error.name, message: error.message, data: error.data },
+ metadata: event.metadata,
} as ErrorEvent);
return (source: Observable<InputEvent>): Observable<CallEvent | ErrorEvent> =>

feat(core): act.operator - pass metadata and error.data to default error event