@@ -11,8 +11,8 @@ import { createSelector } from 'reselect';
11
11
*/
12
12
export class ErrorSelector {
13
13
/**
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
16
16
* HttpErrorResponseModel.
17
17
*
18
18
* @param {IErrorState } errorState
@@ -22,8 +22,10 @@ export class ErrorSelector {
22
22
*/
23
23
static selectRawErrors ( errorState , actionTypes ) {
24
24
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 ;
27
29
}
28
30
29
31
return partialState ;
@@ -41,8 +43,10 @@ export class ErrorSelector {
41
43
*/
42
44
static selectErrorText ( errorState , actionTypes ) {
43
45
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 ;
46
50
const arrayOfErrors = errors . length ? errors : [ message ] ;
47
51
48
52
return errorMessages . concat ( arrayOfErrors ) ;
0 commit comments