Skip to content

Commit 325b790

Browse files
spartan563notheotherben
authored andcommitted
fix: createAction should adhere to doc contract regarding errors
Specifically, the documentation states the following: > If the payload is an instance of an Error object, redux-actions will automatically set action.error to true. This implies that, irrespective of the arguments provided to `createAction`, if the resulting `payload` is an Error object then the `action.error` property should be set to true. This just changes that check to ensure it is performed as stated in the docs.
1 parent 6597603 commit 325b790

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/createAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function createAction(type, actionCreator, metaCreator) {
1313
payload: finalActionCreator(...args)
1414
};
1515

16-
if (args.length === 1 && args[0] instanceof Error) {
16+
if (action.payload instanceof Error) {
1717
// Handle FSA errors where the payload is an Error object. Set error.
1818
action.error = true;
1919
}

0 commit comments

Comments
 (0)