Skip to content
This repository has been archived by the owner on Jul 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #117 from zapier/err-handling
Browse files Browse the repository at this point in the history
fix null error handling
  • Loading branch information
xavdid authored Oct 10, 2018
2 parents cc3b638 + e437874 commit 0506544
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/tools/create-lambda-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ const createLambdaHandler = appRawOrPath => {
// the default behavior with callbacks anyway, but don't want
// to rely on that.
logger(logMsg, logData).then(() => {
if (!constants.IS_TESTING) {
err.message +=
'\n\nConsole logs:\n' +
logBuffer.map(s => ` ${s.message}`).join('');
if (!constants.IS_TESTING && err) {
err.message += `\n\nConsole logs:\n${logBuffer
.map(s => ` ${s.message}`)
.join('')}`;
}
callbackOnce(err);
});
Expand All @@ -181,7 +181,8 @@ const createLambdaHandler = appRawOrPath => {
const handlerDomain = domain.create();

handlerDomain.on('error', err => {
const logMsg = `Uncaught error: ${err}\n${err.stack || '<stack>'}`;
const logMsg = `Uncaught error: ${err}\n${(err && err.stack) ||
'<stack>'}`;
const logData = { err, log_type: 'error' };
logErrorAndCallbackOnce(logMsg, logData, err);
});
Expand All @@ -208,7 +209,8 @@ const createLambdaHandler = appRawOrPath => {
callbackOnce(null, cleaner.maskOutput(output));
})
.catch(err => {
const logMsg = `Unhandled error: ${err}\n${err.stack || '<stack>'}`;
const logMsg = `Unhandled error: ${err}\n${(err && err.stack) ||
'<stack>'}`;
const logData = { err, log_type: 'error' };
logErrorAndCallbackOnce(logMsg, logData, err);
});
Expand Down

0 comments on commit 0506544

Please sign in to comment.