ultrasonicsoft / ng-connection-service

Detects active internet connection in Angular application via DI ready Observable service.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Piles of console error when http fails

TanayBhalani opened this issue · comments

The console.error can be replaced to throwError of rxjs or throw of javascript to prevent the piles of error in console when i do not want.
I faced issue of http error when network was down, and the console was constantly filled with errors, which i have no control on

if the methods throws error i can create a try catch block while subscribing the observable and decide what i want to do of error

tap(val => {
console.error('Http error:', val);
this.currentState.hasInternetAccess = false;
this.emitEvent();
}),

You can check my example to understand the scenario
https://angular-ivy-jzg6ya.stackblitz.io
Repro steps

  1. Click on Start Monitoring button
    image
  2. Open console
    image
  3. Disconnect your device from internet
  4. Observe the console
    image

Note: I have kept try catch block around subscribeMonitor() Method in service check-connection.service.ts but its not able to catch because of console.error() implemented inside the method

okay, I will look into it

Hi @TanayBhalani, please check new version upgrade 9.0.3. Now throwing error when heartBeatUrl is not reachable. You can catch it and handle per your business logic.