From dffda67e37b85403ae5cf3642dd93a5327894511 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 7 Aug 2020 18:18:09 +0300 Subject: [PATCH] feat: handle the remote environment error --- npm/ng-packs/packages/core/src/lib/utils/environment-utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/utils/environment-utils.ts b/npm/ng-packs/packages/core/src/lib/utils/environment-utils.ts index 731d3c61d4..c8d92603f3 100644 --- a/npm/ng-packs/packages/core/src/lib/utils/environment-utils.ts +++ b/npm/ng-packs/packages/core/src/lib/utils/environment-utils.ts @@ -1,10 +1,10 @@ import { HttpClient } from '@angular/common/http'; import { Injector } from '@angular/core'; import { Store } from '@ngxs/store'; -import { of } from 'rxjs'; import { catchError, switchMap } from 'rxjs/operators'; import { SetEnvironment } from '../actions/config.actions'; import { Config } from '../models/config'; +import { RestOccurError } from '../actions/rest.actions'; export function getRemoteEnv(injector: Injector, environment: Partial) { const { remoteEnv } = environment; @@ -17,7 +17,7 @@ export function getRemoteEnv(injector: Injector, environment: Partial(method, url, { headers }) .pipe( - catchError(() => of({} as Config.Environment)), // TODO: Handle error + catchError(err => store.dispatch(new RestOccurError(err))), // TODO: Condiser get handle function from a provider switchMap(env => store.dispatch(new SetEnvironment({ ...environment, ...env }))), ) .toPromise();