blob: 83d11284bd6acc611b98735947261ce9c86050c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
export default function ErrorReducer(state = {}, action) {
const { type, error } = action;
const matches = /(.*)_(REQUEST|FAILED|ERROR)/.exec(
type
);
if (!matches) return state;
const [, requestName, requestState] = matches;
return {
errorMessage:
requestState === "FAILED" || requestState === "ERROR"
? error
? error
: ""
: "",
[requestName]: requestState === "FAILED" || requestState === "ERROR" ? true: false
};
}
|