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













0















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:



enter image description here



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










share|improve this question




























    0















    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:



    enter image description here



    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










    share|improve this question


























      0












      0








      0








      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:



      enter image description here



      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










      share|improve this question
















      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:



      enter image description here



      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago







      sioesi

















      asked 2 days ago









      sioesisioesi

      312217




      312217






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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(...).






          share|improve this answer























          • 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.logs 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










          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
          );



          );













          draft saved

          draft discarded


















          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









          0














          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(...).






          share|improve this answer























          • 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.logs 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















          0














          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(...).






          share|improve this answer























          • 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.logs 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













          0












          0








          0







          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(...).






          share|improve this answer













          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(...).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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 your app.interceptor.ts file, please can you show the code with console.logs 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











          • 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.logs 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.logs 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.logs 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



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현