Show no internet connection if trying to make http request

I used Ionic network to subscribe to internet connection status but I want to show a message say “No internet connection” when making a request and there is no connection.

What code do you have so far? How does what it do differ from what you want it to do?

this code only shows a message when the connection gone or back, what I need is to show a msg to the user if he clicked a button to fetch data from api .

// Handle Network connection
    this.network.onConnect().subscribe(data => {
      this.presentToast("You are Connected");
      console.log(data)
    }, error => console.error(error));

    this.network.onDisconnect().subscribe(data => {
      this.presentToast("You are Offline");
      console.log(data)
    }, error => console.error(error));

The Observable returned from the http request should throw an error in that situation that you can respond to.