I have this simple class :
import {Router} from '@angular/router';
export class NotLogged {
constructor(error, private router: Router) {
alert('Not logged in !');
this.router.navigate(['/']);
}
}
And then I'm trying to call it from a service :
if(error.status === 401)
return Observable.throw(new NotLogged(error.json()));
Of course I get an error Supplied parameters do not match any signature of call target. How can I do that ?
Thanks ahead.
class NotLogged extends Error. And this would be error itself. Class design went wrong.router.navigatereturns a promise and it shouldn't be lost because it may be useful for control flow. Obviously, a promise cannot be returned from error class either.