Skip to content

Instantly share code, notes, and snippets.

@nazreen
Created April 17, 2019 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazreen/814788d6e53609097f11e330d9387ae6 to your computer and use it in GitHub Desktop.
Save nazreen/814788d6e53609097f11e330d9387ae6 to your computer and use it in GitHub Desktop.
2019-04-16 process.on('unresolvedPromise')
// in index.js
...
async function handler(event, context) {
try {
return handlerService.call(event, context, { AWS })
} catch (e) {
if (process.env.NODE_ENV === 'local') throw e
throw JSON.stringify(e)
}
}
// process.on('unresolvedPromise', err => {
// console.error(err.toString())
// process.exit(1)
// })
exports.handler = handler
// handlerServices.js
...
async function call(event, context, options) {
throw new Error('test')
if (!options.AWS) {
throw new Error('Please pass your AWS instance via the "AWS" option.')
}
...
// lambda input is irrelevant since we throw on first line
// result:
{
"errorMessage": "test",
"errorType": "Error",
"stackTrace": [
"Object.call (/var/task/handlers/handlerService.js:7:9)",
"handler (/var/task/index.js:8:27)"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment