-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Description
I'm submitting a ... (check one with "x")
[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
I'm using the Router with Resolver interfaces to get some data form a service (backend) before creating a component which will render the data (subscribing to it).
If an exception occurs in the Resolver the application breaks. (Error: Uncaught (in promise))
Expected behavior
If there is an exception in the Resolver i expect the subscribe error function to be called but the ErrorObservable appears in the "activatedRoute.data.value" instead.
// some component
ngOnInit() {
this.activatedRoute.data
.subscribe(
(data) => {
this.data = data.data] || {};
console.log('data was set to ' + this.data)
},
(error) => {
/// we never get here, no matter there was a Promise.reject(), throw Error(), etc.
console.log('ups! Error getting data')
alert(error);
});
}
// some resolver
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): BehaviorSubject<any>|Observable<any>|Promise<any>|any {
return Observable.throw('This always fails');
}
Minimal reproduction of the problem with instructions
check out the plunker http://plnkr.co/edit/MaiM6T1COr2ppB2AMANx
What is the motivation / use case for changing the behavior?
Catch and treat exceptions within the target component
Please tell us about your environment:
- Angular version: 2.0.X
2.3.1
Yes
- Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
All
- Language: [all | TypeScript X.X | ES6/7 | ES5]
TypeScript 2.1.1 - Node (for AoT issues):
node --version
=