fix: provide a way to handle app config error

pull/8684/head
bnymncoskuner 5 years ago
parent 233256d04e
commit df361fb3d9

@ -0,0 +1,7 @@
import { InjectionToken } from '@angular/core';
export type AppConfigInitErrorFn = (error: any) => void;
export const APP_CONFIG_INITIALIZATION_ERROR = new InjectionToken<AppConfigInitErrorFn[]>(
'APP_CONFIG_INITIALIZATION_ERROR',
);

@ -2,3 +2,4 @@ export * from './list.token';
export * from './lodaer-delay.token';
export * from './manage-profile.token';
export * from './options.token';
export * from './app-config.token';

@ -1,7 +1,8 @@
import { registerLocaleData } from '@angular/common';
import { Injector } from '@angular/core';
import { OAuthService } from 'angular-oauth2-oidc';
import { tap } from 'rxjs/operators';
import { tap, catchError } from 'rxjs/operators';
import { throwError } from 'rxjs';
import { ABP } from '../models/common';
import { Environment } from '../models/environment';
import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service';
@ -12,6 +13,7 @@ import { EnvironmentService } from '../services/environment.service';
import { SessionStateService } from '../services/session-state.service';
import { clearOAuthStorage } from '../strategies/auth-flow.strategy';
import { CORE_OPTIONS } from '../tokens/options.token';
import { APP_CONFIG_INITIALIZATION_ERROR } from '../tokens/app-config.token';
import { getRemoteEnv } from './environment-utils';
import { parseTenantFromUrl } from './multi-tenancy-utils';
@ -38,6 +40,14 @@ export function getInitialData(injector: Injector) {
const currentTenant = configState.getOne('currentTenant') as CurrentTenantDto;
injector.get(SessionStateService).setTenant(currentTenant);
}),
catchError(error => {
const appConfig = injector.get(APP_CONFIG_INITIALIZATION_ERROR);
if (appConfig && appConfig.length) {
appConfig.forEach(fn => fn(error));
}
return throwError(error);
}),
)
.toPromise();
};

Loading…
Cancel
Save