I am connecting to local node from browser like:
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
If there is no node running at localhost, I see an error in browser console:
Error: Invalid JSON RPC response: ""
Is there a way to catch this error and provide useful informations to the user? I have tried adding callbacks to new Web3() and new HttpProvider() calls, but none of them is firing.
let netIsListening = await web3.eth.net.isListening();andtry{}catch(e){}– Andy B. Mar 13 '18 at 15:30awaitstatement if theres no node accepting connections at that address. Posted details at https://ethereum.stackexchange.com/questions/61612/how-to-catch-connection-issues-to-web3-provider-using-web3-js – Nyxynyx Nov 02 '18 at 17:30async ()=>{ try{ let netIsListening = await web3.eth.net.isListening(); }catch(e){ console.error(e); } }– Andy B. Nov 09 '18 at 20:17