How to use the error function from winston

Find comprehensive JavaScript winston.error code examples handpicked from public code repositorys.

66
67
68
69
70
71
72
73
74
75
        return actionForm;
    }
}
catch (err) {
    (0, util_1.sanitizeError)(err);
    winston.error(err);
}
// Return the login form to start over if anything goes wrong during authentication or form construction
// If a user is unauthenticated they are expected to hit an error above
const loginForm = formBuilder.generateLoginForm(hubRequest);
fork icon95
star icon47
watch icon68

+ 39 other calls in file

32
33
34
35
36
37
38
39
40
41
try {
    const actionCrypto = new Hub.ActionCrypto();
    encryptedPayload = yield actionCrypto.encrypt(payloadString);
}
catch (e) {
    winston.error("Payload encryption error:" + e.toString());
    throw e;
}
// Step 1 in the oauth flow - user clicks the button in the form and visits the AH url generated here.
// That response will be auto handled by the AH server as a redirect to the result of oauthUrl function below.
fork icon95
star icon47
watch icon68

+ 15 other calls in file

61
62
63
64
65
66
67
68
69
70
            yield this.sendData(filename, request, drive);
            resp.success = true;
        }
    }
    catch (e) {
        winston.error(`Failed execute for Google Sheets.`, { webhookId: request.webhookId });
        resp.success = false;
        resp.message = e.message;
    }
}
fork icon95
star icon47
watch icon68

+ 15 other calls in file

162
163
164
165
166
167
168
169
170
171
catch (errorReport) {
    const response = new Hub.ActionResponse();
    response.success = false;
    response.message = "Streaming upload failure: " + (0, util_1.sanitizeError)(errorReport);
    // TODO: the oboe fail() handler sends an errorReport object, but that might not be the only thing we catch
    winston.error("Streaming parse failure:" + (0, util_1.sanitizeError)(errorReport + ""));
    if ((errorReport + "").indexOf("CLEANFAIL") >= 0) {
        response.success = true;
    }
    return response;
fork icon95
star icon47
watch icon68

+ 3 other calls in file

193
194
195
196
197
198
199
200
201
202
                err.response.data.error.error_user_title);
            winston.debug("Facebook user friendly message was: " +
                err.response.data.error.error_user_msg);
        }
        // Note that the access token is intentionally omitted from this log
        winston.error(`Error in network request ${method} ${url}` +
            ` with parameters: ${typeof data === "object" && JSON.stringify(data)}.`);
    });
    return response && response.data;
});
fork icon95
star icon47
watch icon68

+ 3 other calls in file

275
276
277
278
279
280
281
282
283
284
}
logInfo(req, res, message, options = {}) {
    winston.info(message, Object.assign(Object.assign({}, options), this.requestLog(req, res)));
}
logError(req, res, message, options = {}) {
    winston.error(message, Object.assign(Object.assign({}, options), this.requestLog(req, res)));
}
requestLog(req, res) {
    return {
        url: req.url,
fork icon95
star icon47
watch icon68

+ 3 other calls in file

183
184
185
186
187
188
189
190
191
192
.read(urlObj[0], urlObj.pop())
.then(async (resource) => {
    resolve(resource.name);
})
.catch((err) => {
    winston.error(err.message);
    let outcome = {...outcomes.ERROR};
    outcome.issue[0].diagnostics = err.message;
    resolve("");
});
fork icon26
star icon26
watch icon0

+ 2 other calls in file

53
54
55
56
57
58
59
60
61
62
    .alias('a', 'append')
    .check(checkArgs)
    .usage("$0 [options] <url file>").argv;

process.on('uncaughtException', function(err) {
    winston.error('Uncaught Exception', err.message);
});

// phantomjs webshot options
var wopts = {
fork icon2
star icon11
watch icon4

+ 7 other calls in file

49
50
51
52
53
54
55
56
57
58
})
app.set('__server_ready__', true)
app.set('__server_live__', true)

server.on('error', function (err) {
  logger.error('Express integrator-extension server error - ' + err.toString())
})

// Timeout should be greater than the server's/load balancer's idle timeout to avoid 504 errors.
server.timeout = config.timeout || 315000
fork icon21
star icon2
watch icon4

+ 2 other calls in file

430
431
432
433
434
435
436
437
438
439
});
child.send({
  uid
});
child.on('error', async err => {
  winston.error(err.stack);
  await db.deleteObjectField('locks', `export:${uid}${type}`);
});
child.on('exit', async () => {
  await db.deleteObjectField('locks', `export:${uid}${type}`);
fork icon1
star icon1
watch icon5

+ 9 other calls in file

114
115
116
117
118
119
120
121
122
123
if (userData.email && userData.uid > 1) {
    await User.email.sendValidationEmail(userData.uid, {
        email: userData.email,
        template: 'welcome',
        subject: `[[email:welcome-to, ${meta.config.title || meta.config.browserTitle || 'NodeBB'}]]`,
    }).catch(err => winston.error(`[user.create] Validation email failed to send\n[emailer.send] ${err.stack}`));
}
if (userNameChanged) {
    await User.notifications.sendNameChangeNotification(userData.uid, userData.username);
}
fork icon1
star icon0
watch icon5

+ 9 other calls in file

130
131
132
133
134
135
136
137
138
139
      subject: `[[email:welcome-to, ${
        meta.config.title || meta.config.browserTitle || "NodeBB"
      }]]`,
    })
    .catch((err) =>
      winston.error(
        `[user.create] Validation email failed to send\n[emailer.send] ${err.stack}`
      )
    );
}
fork icon0
star icon0
watch icon1

+ 12 other calls in file

67
68
69
70
71
72
73
74
75
76
77
    })
  } catch (error) {
    res.status(500).json(
      {message: "Error: " + "Get users error"}
    );
    winston.error(error.message);
  }
});


function createqueryString (cols) {
fork icon0
star icon0
watch icon1

+ 14 other calls in file

173
174
175
176
177
178
179
180
181
182
        const body = await request(url, {
            json: true,
        });
        return await Plugins.normalise(body);
    } catch (err) {
        winston.error(`Error loading ${url}`, err);
        return await Plugins.normalise([]);
    }
};

fork icon0
star icon0
watch icon1

+ 33 other calls in file

49
50
51
52
53
54
55
56
57
58
        });
    }
} catch (err) {
    switch (err.message) {
    case 'dependencies-out-of-date':
        winston.error('One or more of NodeBB\'s dependent packages are out-of-date. Please run the following command to update them:');
        winston.error('    ./nodebb upgrade');
        break;
    case 'dependencies-missing':
        winston.error('One or more of NodeBB\'s dependent packages are missing. Please run the following command to update them:');
fork icon0
star icon0
watch icon1

+ 103 other calls in file

106
107
108
109
110
111
112
113
114
115
116
        '    "password": "",\n' +
        '    "database": "nodebb_test"\n' +
        '}\n' +
        '==========================================================='
    );
    winston.error(errorText);
    throw new Error(errorText);
}


if (testDbConfig.database === productionDbConfig.database &&
fork icon0
star icon0
watch icon1

+ 25 other calls in file

96
97
98
99
100
101
102
103
104
105
if (setupVal['admin:username'] && setupVal['admin:password'] && setupVal['admin:password:confirm'] && setupVal['admin:email']) {
    install.values = setupVal;
} else {
    winston.error('[install/checkSetupFlagEnv] required values are missing for automated setup:');
    if (!setupVal['admin:username']) {
        winston.error('  admin:username');
    }
    if (!setupVal['admin:password']) {
        winston.error('  admin:password');
    }
fork icon0
star icon0
watch icon1

+ 43 other calls in file

130
131
132
133
134
135
136
137
138
139
  // res.status(429).send(`Too many requests. Retry after ${retrySecs} seconds.`)
  res.status(429).render('429', { timeout: retrySecs.toString(), layout: false })
} else {
  passport.authenticate('local', async function (err, user) {
    if (err) {
      winston.error(err)
      return next(err)
    }
    if (!user) {
      try {
fork icon0
star icon0
watch icon1

+ 41 other calls in file

84
85
86
87
88
89
90
91
92

    
    client.set(key, data, 'EX', WEATHER_EXPIRATION_TIME);
  } catch (err) {
   
    winston.error(`Error fetching weather data for ${city}: ${err}`);
    throw err;
  }
}
fork icon0
star icon0
watch icon1

+ 17 other calls in file

164
165
166
167
168
169
170
171
172
173
    //console.log(description);
    return description;
  }
  catch (e) {
    console.log(e);
    logger.error(e.message);
    return description;
  }
};
 
fork icon0
star icon0
watch icon1

+ 21 other calls in file