Browse Source

feat: handle the remote environment error

pull/4967/head
mehmet-erim 6 years ago
parent
commit
dffda67e37
  1. 4
      npm/ng-packs/packages/core/src/lib/utils/environment-utils.ts

4
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<Config.Environment>) {
const { remoteEnv } = environment;
@ -17,7 +17,7 @@ export function getRemoteEnv(injector: Injector, environment: Partial<Config.Env
return http
.request<Config.Environment>(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();

Loading…
Cancel
Save