Skip to content

Commit c420a95

Browse files
author
Robert S
committed
make code more readable
1 parent c30248b commit c420a95

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/selectors/error/ErrorSelector.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { createSelector } from 'reselect';
1111
*/
1212
export class ErrorSelector {
1313
/**
14-
* Creates a new object with the key being the finished action type
15-
* (e.g. "SomeAction.REQUEST_*_FINISHED") and the value being the
14+
* Returns a new object with the keys being the finished action type
15+
* (e.g. "SomeAction.REQUEST_*_FINISHED") and the value being a
1616
* HttpErrorResponseModel.
1717
*
1818
* @param {IErrorState} errorState
@@ -22,8 +22,10 @@ export class ErrorSelector {
2222
*/
2323
static selectRawErrors(errorState, actionTypes) {
2424
return actionTypes.reduce((partialState, actionType) => {
25-
if (errorState[actionType]) {
26-
partialState[actionType] = errorState[actionType];
25+
const httpErrorResponseModel = errorState[actionType];
26+
27+
if (httpErrorResponseModel) {
28+
partialState[actionType] = httpErrorResponseModel;
2729
}
2830

2931
return partialState;
@@ -41,8 +43,10 @@ export class ErrorSelector {
4143
*/
4244
static selectErrorText(errorState, actionTypes) {
4345
const errorList = actionTypes.reduce((errorMessages, actionType) => {
44-
if (errorState[actionType]) {
45-
const { message, errors } = errorState[actionType];
46+
const httpErrorResponseModel = errorState[actionType];
47+
48+
if (httpErrorResponseModel) {
49+
const { message, errors } = httpErrorResponseModel;
4650
const arrayOfErrors = errors.length ? errors : [message];
4751

4852
return errorMessages.concat(arrayOfErrors);

0 commit comments

Comments
 (0)