javascript – Error handling at the beginning of the promise chain

I'm trying to find a general way to handle errors in the chains of promise. Next, I would like to control a possible connection error directly in my connection.js.

conexion.js

getData () {function
Search again (myEndpoint)
.catch (err => handleConnectionError (err)) // redirect to the error page or similar
}

app.js

// import connection
connection.getData ()
.then (data => handleData (data.foo))

So there are two ways in which this scenario could develop:

  • If I detect the error in connection.js without releasing a new one, it will continue with the promise chain and the HandData () will fail.
  • If I throw an error again after handling it, the promise chain will not run anymore, but then I have a promise rejection error not handled in the console.

So, is there really no better way to capture and handle errors every time I'm using the getData () function somewhere in my application?