Skip to content

Commit 32b9140

Browse files
committed
added error handler for no network connection
1 parent db2e6c4 commit 32b9140

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@ var Logsene = function (options) {
4444
options.type || 'winston_logsene',
4545
options.url)
4646
var self = this
47-
this.logger.on('error', function (err) {
48-
self.emit('error', err)
47+
this.logger.on('error', function (e) {
48+
const { err } = e
49+
50+
if (err.code === 'EAI_AGAIN') {
51+
console.log(new Date().toISOString() + ` winston-logsene: cannot reach the receiver URL: ${err.url}, please check your network connection ...`)
52+
return
53+
}
54+
55+
self.emit('error', e)
4956
})
5057
this.logger.on('log', function (data) {
5158
self.logCount = self.logCount - data.count

0 commit comments

Comments
 (0)