@@ -11,8 +11,8 @@ import { createSelector } from 'reselect';
1111 */
1212export 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