As you know it\'s possible to use Interceptors in new versions of Angular 4.
In mine, I want to cancel a request in interceptor in some conditions. So i
Inspired by @RVP answer I have found out that it's possible to cut the chain with an error in the same simple way using Observable.throw()
//...
intercept(req: HttpRequest, next: HttpHandler): Observable> {
if (stopThisRequestWithError) {
return Observable.throw('Error message');
} else {
return next.handle(req);
}
}
This avoids fulfilling response promises with undefined values.