Commit 57064ade authored by David Burke's avatar David Burke

handle error effect doesn't need observables

parent d3b73e26
Pipeline #36201884 passed with stages
in 8 minutes and 39 seconds
......@@ -5,7 +5,7 @@ import {
exhaustMap,
catchError
} from "rxjs/operators";
import { of as observableOf, of, from } from "rxjs";
import { of, from } from "rxjs";
import { Injectable } from "@angular/core";
import { Router } from "@angular/router";
......@@ -114,12 +114,12 @@ export class LoginEffects {
handleAPIError$ = this.actions$.pipe(
ofType<HandleAPIErrorAction>(AccountActionTypes.HANDLE_API_ERROR),
map(action => action.payload),
exhaustMap(err => {
map(err => {
const res: HttpErrorResponse = err.res;
if (res) {
if (res.status === 0) {
// Not so bad, network is just down
return observableOf(new APIFailureNetworkDownAction());
return new APIFailureNetworkDownAction();
}
if ([401, 403].includes(res.status)) {
if (
......@@ -127,19 +127,19 @@ export class LoginEffects {
res.error &&
res.error.detail === "User's email is not confirmed."
) {
return observableOf(new UserMustConfirmEmailAction());
return new UserMustConfirmEmailAction();
}
return observableOf(new LogoutAction());
return new LogoutAction();
}
}
if (err.name === "Passit SDK Authentication Error") {
return observableOf(new LogoutAction());
return new LogoutAction();
}
// This should never run
console.error("Unable to use api and unable to handle error", err);
return observableOf(new CriticalAPIErrorAction(err));
return new CriticalAPIErrorAction(err);
})
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment