I have the following code that handles http requests.
request.connection.addListener('close', function(had_error) { console.log(had_error); ...
I want to print more error information, but it only prints "true".
P粉6626142132024-04-04 08:08:06
Use Error events to track errors. It returns an Error object containing complete details.
request.connection.addListener('error', function(error) { console.log(error.reason|| error.message); });
Since the connection has been deprecated since v15, you can also use it if you are using the latest version
request.on('error',function(error){ console.log(error.reason|| error.message); });