Interceptor dont capture some errorsInfinite loop in interceptorAngular View doesnt update after http interceptorImplement http request in interceptor angular2Angular 4 and OAuth - Intercept 401 responses, refresh the access token and retry requestHttpErrorResponse can not get expected response from HttpServletResponseAngular 5 interceptor ignores part of the codeHow can I prevent the Angular 6 Custom-Reuse-Strategy from caching a 403 forbidden page?Http response is detected but view is not updated using Angular 6.xUnauthorized Error From Server when send Request to Server in Angular6Angular intercepting http errors
why `nmap 192.168.1.97` returns less services than `nmap 127.0.0.1`?
Drawing ramified coverings with tikz
Creepy dinosaur pc game identification
Is it better practice to read straight from sheet music rather than memorize it?
Open a doc from terminal, but not by its name
Can someone explain how this makes sense electrically?
Has any country ever had 2 former presidents in jail simultaneously?
What are the purposes of autoencoders?
What is Cash Advance APR?
How to explain what's wrong with this application of the chain rule?
Why should universal income be universal?
How do I color the graph in datavisualization?
Why electric field inside a cavity of a non-conducting sphere not zero?
A social experiment. What is the worst that can happen?
Non-trope happy ending?
How could a planet have erratic days?
Problem with TransformedDistribution
When a Cleric spontaneously casts a Cure Light Wounds spell, will a Pearl of Power recover the original spell or Cure Light Wounds?
Loading commands from file
Is the U.S. Code copyrighted by the Government?
Pre-mixing cryogenic fuels and using only one fuel tank
Not using 's' for he/she/it
Why did the HMS Bounty go back to a time when whales are already rare?
How can we generalize the fact of finite dimensional vector space to an infinte dimensional case?
Interceptor dont capture some errors
Infinite loop in interceptorAngular View doesnt update after http interceptorImplement http request in interceptor angular2Angular 4 and OAuth - Intercept 401 responses, refresh the access token and retry requestHttpErrorResponse can not get expected response from HttpServletResponseAngular 5 interceptor ignores part of the codeHow can I prevent the Angular 6 Custom-Reuse-Strategy from caching a 403 forbidden page?Http response is detected but view is not updated using Angular 6.xUnauthorized Error From Server when send Request to Server in Angular6Angular intercepting http errors
I'm having a problem, implement in my application Ionic 3 (angular 5) interceptor for the authentication of the apis I consume. I am forcing the failure by adding another string to the Bearer, something that is invalid and can capture the errors, however, in the first instance it works, more in the second call it does not fall into the error (however the api responds an error 403)
addAuthHeader(request)
return request.clone(
setHeaders:
"Authorization": 'Bearer ' + _.get(this.localStorageService.getAccessToken(), 'accessToken', '')
);
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
//console.log(_.get(req, 'url', ''));
console.log(req);
return next.handle(req).pipe(catchError(err =>
if (err instanceof HttpErrorResponse)
let statusError = _.get(err, 'status', 0);
console.log(err);
if (statusError == 401
))
I am the results:
As you can see, the first call fails and the error is an HttpErrorResponse
, while in the second it also fails but the error is a simple HttpRequest
angular ionic3 angular-http-interceptors
add a comment |
I'm having a problem, implement in my application Ionic 3 (angular 5) interceptor for the authentication of the apis I consume. I am forcing the failure by adding another string to the Bearer, something that is invalid and can capture the errors, however, in the first instance it works, more in the second call it does not fall into the error (however the api responds an error 403)
addAuthHeader(request)
return request.clone(
setHeaders:
"Authorization": 'Bearer ' + _.get(this.localStorageService.getAccessToken(), 'accessToken', '')
);
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
//console.log(_.get(req, 'url', ''));
console.log(req);
return next.handle(req).pipe(catchError(err =>
if (err instanceof HttpErrorResponse)
let statusError = _.get(err, 'status', 0);
console.log(err);
if (statusError == 401
))
I am the results:
As you can see, the first call fails and the error is an HttpErrorResponse
, while in the second it also fails but the error is a simple HttpRequest
angular ionic3 angular-http-interceptors
add a comment |
I'm having a problem, implement in my application Ionic 3 (angular 5) interceptor for the authentication of the apis I consume. I am forcing the failure by adding another string to the Bearer, something that is invalid and can capture the errors, however, in the first instance it works, more in the second call it does not fall into the error (however the api responds an error 403)
addAuthHeader(request)
return request.clone(
setHeaders:
"Authorization": 'Bearer ' + _.get(this.localStorageService.getAccessToken(), 'accessToken', '')
);
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
//console.log(_.get(req, 'url', ''));
console.log(req);
return next.handle(req).pipe(catchError(err =>
if (err instanceof HttpErrorResponse)
let statusError = _.get(err, 'status', 0);
console.log(err);
if (statusError == 401
))
I am the results:
As you can see, the first call fails and the error is an HttpErrorResponse
, while in the second it also fails but the error is a simple HttpRequest
angular ionic3 angular-http-interceptors
I'm having a problem, implement in my application Ionic 3 (angular 5) interceptor for the authentication of the apis I consume. I am forcing the failure by adding another string to the Bearer, something that is invalid and can capture the errors, however, in the first instance it works, more in the second call it does not fall into the error (however the api responds an error 403)
addAuthHeader(request)
return request.clone(
setHeaders:
"Authorization": 'Bearer ' + _.get(this.localStorageService.getAccessToken(), 'accessToken', '')
);
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
//console.log(_.get(req, 'url', ''));
console.log(req);
return next.handle(req).pipe(catchError(err =>
if (err instanceof HttpErrorResponse)
let statusError = _.get(err, 'status', 0);
console.log(err);
if (statusError == 401
))
I am the results:
As you can see, the first call fails and the error is an HttpErrorResponse
, while in the second it also fails but the error is a simple HttpRequest
angular ionic3 angular-http-interceptors
angular ionic3 angular-http-interceptors
edited 2 days ago
sioesi
asked 2 days ago
sioesisioesi
312217
312217
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
As you said, the first error is an instance of HttpErrorResponse
while the others are HttpRequest
so they don't pass into your condition:
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
return next.handle(req).pipe(catchError(err =>
if (err instanceof HttpErrorResponse) // <------ This condition
// If not HttpErrorResponse, don't go here...
// ...
))
So that's a good behavior of your interceptor. You need to check if your observables are returning errors well, and if you made them yourself, check that you handle errors with observer.error(...)
.
Is that the second (HttpRequest) the browser reports an error, the Network screen marks me the request with a 403, that's why I do not understand why it does not capture it as an error. The call to the services are responding well, since in the first instance if it fails and returns the error.
– sioesi
2 days ago
I saw in your screenshots that you are logging two lines (59 and 66) of yourapp.interceptor.ts
file, please can you show the code withconsole.log
s in order to understand your issue better
– Maxime Lafarie
2 days ago
Update my code, those are the lines that I am printing.
– sioesi
2 days ago
Thanks. Something strange is that there's one error (red line) that is emitted by your API call and the last by a polyfill...
– Maxime Lafarie
2 days ago
1
Exactly, that's why I do not understand if it enters the Interceptor as an error or not
– sioesi
2 days ago
|
show 4 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281359%2finterceptor-dont-capture-some-errors%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As you said, the first error is an instance of HttpErrorResponse
while the others are HttpRequest
so they don't pass into your condition:
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
return next.handle(req).pipe(catchError(err =>
if (err instanceof HttpErrorResponse) // <------ This condition
// If not HttpErrorResponse, don't go here...
// ...
))
So that's a good behavior of your interceptor. You need to check if your observables are returning errors well, and if you made them yourself, check that you handle errors with observer.error(...)
.
Is that the second (HttpRequest) the browser reports an error, the Network screen marks me the request with a 403, that's why I do not understand why it does not capture it as an error. The call to the services are responding well, since in the first instance if it fails and returns the error.
– sioesi
2 days ago
I saw in your screenshots that you are logging two lines (59 and 66) of yourapp.interceptor.ts
file, please can you show the code withconsole.log
s in order to understand your issue better
– Maxime Lafarie
2 days ago
Update my code, those are the lines that I am printing.
– sioesi
2 days ago
Thanks. Something strange is that there's one error (red line) that is emitted by your API call and the last by a polyfill...
– Maxime Lafarie
2 days ago
1
Exactly, that's why I do not understand if it enters the Interceptor as an error or not
– sioesi
2 days ago
|
show 4 more comments
As you said, the first error is an instance of HttpErrorResponse
while the others are HttpRequest
so they don't pass into your condition:
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
return next.handle(req).pipe(catchError(err =>
if (err instanceof HttpErrorResponse) // <------ This condition
// If not HttpErrorResponse, don't go here...
// ...
))
So that's a good behavior of your interceptor. You need to check if your observables are returning errors well, and if you made them yourself, check that you handle errors with observer.error(...)
.
Is that the second (HttpRequest) the browser reports an error, the Network screen marks me the request with a 403, that's why I do not understand why it does not capture it as an error. The call to the services are responding well, since in the first instance if it fails and returns the error.
– sioesi
2 days ago
I saw in your screenshots that you are logging two lines (59 and 66) of yourapp.interceptor.ts
file, please can you show the code withconsole.log
s in order to understand your issue better
– Maxime Lafarie
2 days ago
Update my code, those are the lines that I am printing.
– sioesi
2 days ago
Thanks. Something strange is that there's one error (red line) that is emitted by your API call and the last by a polyfill...
– Maxime Lafarie
2 days ago
1
Exactly, that's why I do not understand if it enters the Interceptor as an error or not
– sioesi
2 days ago
|
show 4 more comments
As you said, the first error is an instance of HttpErrorResponse
while the others are HttpRequest
so they don't pass into your condition:
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
return next.handle(req).pipe(catchError(err =>
if (err instanceof HttpErrorResponse) // <------ This condition
// If not HttpErrorResponse, don't go here...
// ...
))
So that's a good behavior of your interceptor. You need to check if your observables are returning errors well, and if you made them yourself, check that you handle errors with observer.error(...)
.
As you said, the first error is an instance of HttpErrorResponse
while the others are HttpRequest
so they don't pass into your condition:
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
return next.handle(req).pipe(catchError(err =>
if (err instanceof HttpErrorResponse) // <------ This condition
// If not HttpErrorResponse, don't go here...
// ...
))
So that's a good behavior of your interceptor. You need to check if your observables are returning errors well, and if you made them yourself, check that you handle errors with observer.error(...)
.
answered 2 days ago
Maxime LafarieMaxime Lafarie
7961726
7961726
Is that the second (HttpRequest) the browser reports an error, the Network screen marks me the request with a 403, that's why I do not understand why it does not capture it as an error. The call to the services are responding well, since in the first instance if it fails and returns the error.
– sioesi
2 days ago
I saw in your screenshots that you are logging two lines (59 and 66) of yourapp.interceptor.ts
file, please can you show the code withconsole.log
s in order to understand your issue better
– Maxime Lafarie
2 days ago
Update my code, those are the lines that I am printing.
– sioesi
2 days ago
Thanks. Something strange is that there's one error (red line) that is emitted by your API call and the last by a polyfill...
– Maxime Lafarie
2 days ago
1
Exactly, that's why I do not understand if it enters the Interceptor as an error or not
– sioesi
2 days ago
|
show 4 more comments
Is that the second (HttpRequest) the browser reports an error, the Network screen marks me the request with a 403, that's why I do not understand why it does not capture it as an error. The call to the services are responding well, since in the first instance if it fails and returns the error.
– sioesi
2 days ago
I saw in your screenshots that you are logging two lines (59 and 66) of yourapp.interceptor.ts
file, please can you show the code withconsole.log
s in order to understand your issue better
– Maxime Lafarie
2 days ago
Update my code, those are the lines that I am printing.
– sioesi
2 days ago
Thanks. Something strange is that there's one error (red line) that is emitted by your API call and the last by a polyfill...
– Maxime Lafarie
2 days ago
1
Exactly, that's why I do not understand if it enters the Interceptor as an error or not
– sioesi
2 days ago
Is that the second (HttpRequest) the browser reports an error, the Network screen marks me the request with a 403, that's why I do not understand why it does not capture it as an error. The call to the services are responding well, since in the first instance if it fails and returns the error.
– sioesi
2 days ago
Is that the second (HttpRequest) the browser reports an error, the Network screen marks me the request with a 403, that's why I do not understand why it does not capture it as an error. The call to the services are responding well, since in the first instance if it fails and returns the error.
– sioesi
2 days ago
I saw in your screenshots that you are logging two lines (59 and 66) of your
app.interceptor.ts
file, please can you show the code with console.log
s in order to understand your issue better– Maxime Lafarie
2 days ago
I saw in your screenshots that you are logging two lines (59 and 66) of your
app.interceptor.ts
file, please can you show the code with console.log
s in order to understand your issue better– Maxime Lafarie
2 days ago
Update my code, those are the lines that I am printing.
– sioesi
2 days ago
Update my code, those are the lines that I am printing.
– sioesi
2 days ago
Thanks. Something strange is that there's one error (red line) that is emitted by your API call and the last by a polyfill...
– Maxime Lafarie
2 days ago
Thanks. Something strange is that there's one error (red line) that is emitted by your API call and the last by a polyfill...
– Maxime Lafarie
2 days ago
1
1
Exactly, that's why I do not understand if it enters the Interceptor as an error or not
– sioesi
2 days ago
Exactly, that's why I do not understand if it enters the Interceptor as an error or not
– sioesi
2 days ago
|
show 4 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281359%2finterceptor-dont-capture-some-errors%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown