Skip to content

Commit

Permalink
add docs url to error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Cooper authored and Stephen Cooper committed Feb 10, 2020
1 parent 3c27f64 commit ac28681
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('inNgZoneAssertMetaReducer:', () => {
.createSpy('isInAngularZone')
.and.returnValue(false);
expect(() => invokeActionReducer((state: any) => state)).toThrowError(
`strictActionWithinNgZone: Action 'invoke' running outside NgZone.`
`Action 'invoke' running outside NgZone. https://ngrx.io/guide/store/configuration/runtime-checks#strictactionwithinngzone`
);
expect(ngCore.NgZone.isInAngularZone).toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('serializationCheckMetaReducer:', () => {
payload: { foo: { bar: unSerializables['date'] } },
})
).toThrowError(
/Detected unserializable action at "payload.foo.bar.value"/
`Detected unserializable action at "payload.foo.bar.value". https://ngrx.io/guide/store/configuration/runtime-checks#strictactionserializability`
);
});
});
Expand All @@ -80,13 +80,13 @@ describe('serializationCheckMetaReducer:', () => {
).toThrowError(/Detected unserializable state at "foo.bar.value"/);
});

it('should not throw if state is null', () => {
it('should throw if state is null', () => {
expect(() => invokeStateReducer(null)).toThrowError(
/Detected unserializable state at "root"/
`Detected unserializable state at "root". https://ngrx.io/guide/store/configuration/runtime-checks#strictstateserializability`
);
});

it('should not throw if state is undefined', () => {
it('should throw if state is undefined', () => {
expect(() => invokeStateReducer(undefined)).toThrowError(
/Detected unserializable state at "root"/
);
Expand Down
2 changes: 1 addition & 1 deletion modules/store/spec/runtime_checks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ describe('Runtime checks:', () => {
store.dispatch(invalidAction());
flush();
}).toThrowError(
"strictActionWithinNgZone: Action 'Action triggered outside of NgZone' running outside NgZone."
"Action 'Action triggered outside of NgZone' running outside NgZone. https://ngrx.io/guide/store/configuration/runtime-checks#strictactionwithinngzone"
);
})
);
Expand Down
7 changes: 4 additions & 3 deletions modules/store/src/meta-reducers/inNgZoneAssert_reducer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as ngCore from '@angular/core';
import { ActionReducer, Action } from '../models';
import { Action, ActionReducer } from '../models';
import { RUNTIME_CHECK_URL } from './utils';

export function inNgZoneAssertMetaReducer(
reducer: ActionReducer<any, Action>,
Expand All @@ -8,9 +9,9 @@ export function inNgZoneAssertMetaReducer(
return function(state: any, action: Action) {
if (checks.action(action) && !ngCore.NgZone.isInAngularZone()) {
throw new Error(
`strictActionWithinNgZone: Action '${
`Action '${
action.type
}' running outside NgZone.`
}' running outside NgZone. ${RUNTIME_CHECK_URL}#strictactionwithinngzone`
);
}
return reducer(state, action);
Expand Down
3 changes: 2 additions & 1 deletion modules/store/src/meta-reducers/serialization_reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
isBoolean,
isString,
isArray,
RUNTIME_CHECK_URL,
} from './utils';

export function serializationCheckMetaReducer(
Expand Down Expand Up @@ -82,7 +83,7 @@ function throwIfUnserializable(

const unserializablePath = unserializable.path.join('.');
const error: any = new Error(
`Detected unserializable ${context} at "${unserializablePath}"`
`Detected unserializable ${context} at "${unserializablePath}". ${RUNTIME_CHECK_URL}#strict${context}serializability`
);
error.value = unserializable.value;
error.unserializablePath = unserializablePath;
Expand Down
3 changes: 3 additions & 0 deletions modules/store/src/meta-reducers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export const RUNTIME_CHECK_URL =
'https://ngrx.io/guide/store/configuration/runtime-checks';

export function isUndefined(target: any): target is undefined {
return target === undefined;
}
Expand Down

0 comments on commit ac28681

Please sign in to comment.