I can't seem to figure out a way to catch/handle errors inside forkJoin while trying to do route resolve.
I've created a route resolver for Account page and It should return 2 requests before routing. Now here is the part I cant work out: If user doesn't have a subscription then 404 is returned from server. I would like to handle this and if it happens, user should be routed to a different page, from where he could make subscription.
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import { AccountService } from './account.service';
@Injectable()
export class AccountResolver implements Resolve<any> {
constructor(private accountService: AccountService) { }
resolve(route: ActivatedRouteSnapshot): Observable<any> {
return Observable.forkJoin([
this.accountService.getUser(),
this.accountService.getUserSubscriptions()
]);
};
}
How do I catch and handle error 404 sent by server when getUserSubscriptions() is requested?