Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular UI: Return observable from catchErrors #10055

Merged
merged 2 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
OAuthErrorEvent,
OAuthInfoEvent,
OAuthService,
OAuthStorage,
OAuthStorage
} from 'angular-oauth2-oidc';
import { from, Observable, of, pipe } from 'rxjs';
import { filter, switchMap, tap } from 'rxjs/operators';
Expand Down Expand Up @@ -37,7 +37,10 @@ export abstract class AuthFlowStrategy {
abstract logout(queryParams?: Params): Observable<any>;
abstract login(params?: LoginParams | Params): Observable<any>;

private catchError = err => this.httpErrorReporter.reportError(err);
private catchError = err => {
this.httpErrorReporter.reportError(err);
return of(null);
};

constructor(protected injector: Injector) {
this.httpErrorReporter = injector.get(HttpErrorReporterService);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HttpClient } from '@angular/common/http';
import { Injector } from '@angular/core';
import { of } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
import { Environment, RemoteEnv } from '../models/environment';
import { EnvironmentService } from '../services/environment.service';
Expand All @@ -19,7 +20,10 @@ export function getRemoteEnv(injector: Injector, environment: Partial<Environmen
return http
.request<Environment>(method, url, { headers })
.pipe(
catchError(err => httpErrorReporter.reportError(err)), // TODO: Condiser get handle function from a provider
catchError(err => {
httpErrorReporter.reportError(err);
return of(null);
}), // TODO: Consider get handle function from a provider
tap(env => environmentService.setState(mergeEnvironments(environment, env, remoteEnv))),
)
.toPromise();
Expand Down