Skip to content

Commit f0ca6fb

Browse files
committed
Update handling of failure in RSAA descriptor custom methods
This is a follow-up to #175, which updated this behavior and docs for failed fetches, to include failures in RSAA custom methods, such as `[RSAA].headers`
1 parent c424041 commit f0ca6fb

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

src/__snapshots__/middleware.test.js.snap

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,9 @@ exports[`#apiMiddleware must dispatch an error request FSA for an invalid RSAA w
864864
exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].bailout fails: final result 1`] = `
865865
Object {
866866
"error": true,
867-
"meta": "someMeta",
867+
"meta": undefined,
868868
"payload": [RequestError: [RSAA].bailout function failed],
869-
"type": "REQUEST",
869+
"type": "FAILURE",
870870
}
871871
`;
872872
@@ -876,9 +876,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].bailout f
876876
Array [
877877
Object {
878878
"error": true,
879-
"meta": "someMeta",
879+
"meta": undefined,
880880
"payload": [RequestError: [RSAA].bailout function failed],
881-
"type": "REQUEST",
881+
"type": "FAILURE",
882882
},
883883
],
884884
],
@@ -887,9 +887,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].bailout f
887887
"isThrow": false,
888888
"value": Object {
889889
"error": true,
890-
"meta": "someMeta",
890+
"meta": undefined,
891891
"payload": [RequestError: [RSAA].bailout function failed],
892-
"type": "REQUEST",
892+
"type": "FAILURE",
893893
},
894894
},
895895
],
@@ -899,9 +899,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].bailout f
899899
exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].body fails: final result 1`] = `
900900
Object {
901901
"error": true,
902-
"meta": "someMeta",
902+
"meta": undefined,
903903
"payload": [RequestError: [RSAA].body function failed],
904-
"type": "REQUEST",
904+
"type": "FAILURE",
905905
}
906906
`;
907907
@@ -911,9 +911,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].body fail
911911
Array [
912912
Object {
913913
"error": true,
914-
"meta": "someMeta",
914+
"meta": undefined,
915915
"payload": [RequestError: [RSAA].body function failed],
916-
"type": "REQUEST",
916+
"type": "FAILURE",
917917
},
918918
],
919919
],
@@ -922,9 +922,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].body fail
922922
"isThrow": false,
923923
"value": Object {
924924
"error": true,
925-
"meta": "someMeta",
925+
"meta": undefined,
926926
"payload": [RequestError: [RSAA].body function failed],
927-
"type": "REQUEST",
927+
"type": "FAILURE",
928928
},
929929
},
930930
],
@@ -934,9 +934,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].body fail
934934
exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].endpoint fails: final result 1`] = `
935935
Object {
936936
"error": true,
937-
"meta": "someMeta",
937+
"meta": undefined,
938938
"payload": [RequestError: [RSAA].endpoint function failed],
939-
"type": "REQUEST",
939+
"type": "FAILURE",
940940
}
941941
`;
942942
@@ -946,9 +946,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].endpoint
946946
Array [
947947
Object {
948948
"error": true,
949-
"meta": "someMeta",
949+
"meta": undefined,
950950
"payload": [RequestError: [RSAA].endpoint function failed],
951-
"type": "REQUEST",
951+
"type": "FAILURE",
952952
},
953953
],
954954
],
@@ -957,9 +957,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].endpoint
957957
"isThrow": false,
958958
"value": Object {
959959
"error": true,
960-
"meta": "someMeta",
960+
"meta": undefined,
961961
"payload": [RequestError: [RSAA].endpoint function failed],
962-
"type": "REQUEST",
962+
"type": "FAILURE",
963963
},
964964
},
965965
],
@@ -969,9 +969,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].endpoint
969969
exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].headers fails: final result 1`] = `
970970
Object {
971971
"error": true,
972-
"meta": "someMeta",
972+
"meta": undefined,
973973
"payload": [RequestError: [RSAA].headers function failed],
974-
"type": "REQUEST",
974+
"type": "FAILURE",
975975
}
976976
`;
977977
@@ -981,9 +981,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].headers f
981981
Array [
982982
Object {
983983
"error": true,
984-
"meta": "someMeta",
984+
"meta": undefined,
985985
"payload": [RequestError: [RSAA].headers function failed],
986-
"type": "REQUEST",
986+
"type": "FAILURE",
987987
},
988988
],
989989
],
@@ -992,9 +992,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].headers f
992992
"isThrow": false,
993993
"value": Object {
994994
"error": true,
995-
"meta": "someMeta",
995+
"meta": undefined,
996996
"payload": [RequestError: [RSAA].headers function failed],
997-
"type": "REQUEST",
997+
"type": "FAILURE",
998998
},
999999
},
10001000
],
@@ -1076,9 +1076,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].ok fails:
10761076
exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].options fails: final result 1`] = `
10771077
Object {
10781078
"error": true,
1079-
"meta": "someMeta",
1079+
"meta": undefined,
10801080
"payload": [RequestError: [RSAA].options function failed],
1081-
"type": "REQUEST",
1081+
"type": "FAILURE",
10821082
}
10831083
`;
10841084
@@ -1088,9 +1088,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].options f
10881088
Array [
10891089
Object {
10901090
"error": true,
1091-
"meta": "someMeta",
1091+
"meta": undefined,
10921092
"payload": [RequestError: [RSAA].options function failed],
1093-
"type": "REQUEST",
1093+
"type": "FAILURE",
10941094
},
10951095
],
10961096
],
@@ -1099,9 +1099,9 @@ exports[`#apiMiddleware must dispatch an error request FSA when [RSAA].options f
10991099
"isThrow": false,
11001100
"value": Object {
11011101
"error": true,
1102-
"meta": "someMeta",
1102+
"meta": undefined,
11031103
"payload": [RequestError: [RSAA].options function failed],
1104-
"type": "REQUEST",
1104+
"type": "FAILURE",
11051105
},
11061106
},
11071107
],

src/middleware.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function createMiddleware(options = {}) {
7676
return next(
7777
await actionWith(
7878
{
79-
...requestType,
79+
...failureType,
8080
payload: new RequestError('[RSAA].bailout function failed'),
8181
error: true
8282
},
@@ -93,7 +93,7 @@ function createMiddleware(options = {}) {
9393
return next(
9494
await actionWith(
9595
{
96-
...requestType,
96+
...failureType,
9797
payload: new RequestError('[RSAA].endpoint function failed'),
9898
error: true
9999
},
@@ -111,7 +111,7 @@ function createMiddleware(options = {}) {
111111
return next(
112112
await actionWith(
113113
{
114-
...requestType,
114+
...failureType,
115115
payload: new RequestError('[RSAA].body function failed'),
116116
error: true
117117
},
@@ -129,7 +129,7 @@ function createMiddleware(options = {}) {
129129
return next(
130130
await actionWith(
131131
{
132-
...requestType,
132+
...failureType,
133133
payload: new RequestError('[RSAA].headers function failed'),
134134
error: true
135135
},
@@ -147,7 +147,7 @@ function createMiddleware(options = {}) {
147147
return next(
148148
await actionWith(
149149
{
150-
...requestType,
150+
...failureType,
151151
payload: new RequestError('[RSAA].options function failed'),
152152
error: true
153153
},

0 commit comments

Comments
 (0)