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

fix null error handling #117

Merged
merged 1 commit into from
Oct 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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