diff --git a/src/utils/serve-functions.js b/src/utils/serve-functions.js index 80994d7451c..f3b6325390b 100644 --- a/src/utils/serve-functions.js +++ b/src/utils/serve-functions.js @@ -19,9 +19,13 @@ const { detectFunctionsBuilder } = require('./detect-functions-builder') function handleErr(err, response) { response.statusCode = 500 - response.write(`${NETLIFYDEVERR} Function invocation failed: ` + err.toString()) + const errorString = + err instanceof Error + ? `${err.name}: ${err.message}\n\t${err.stack.join('\n\t')}` // Normal JS error + : `${err.errorType}: ${err.errorMessage}\n\t${err.stackTrace.join('\n\t')}` // Error manipulated by lambda-local + response.write(`Function invocation failed: ${errorString}`) response.end() - console.log(`${NETLIFYDEVERR} Error during invocation:`, err) + console.log(`${NETLIFYDEVERR} Function invocation failed:`, errorString) } function capitalize(t) {