pambda-errorhandler
Error handler pambda.
Installation
npm i pambda-errorhandler
Usage
;;const handler =;
API
errorhandler(options)
options.renderError
- The function with argument
(err, event, context, callback)
, called when an error occurs in subsequent Pambdas. - Default value is
defaultErrorResponse
.
- The function with argument
options.errorNotificationArn
- A topic ARN of SNS for publishing an error.
- Default value is
process.env.ERROR_NOTIFICATION_ARN
.
options.errorNotificationTopicName
- A topic name of SNS for publishing an error.
- If the
options.errorNotificationArn
is specified, this option is ignored.
If the options.errorNotificationArn
is used, such as the following configuration is needed in your SAM template:
Resources:YourLambda:Type: AWS::Serverless::FunctionProperties:Policies:- SNSPublishMessagePolicy:TopicName: yourSnsTopicNameEnvironment:Variables:ERROR_NOTIFICATION_ARN: !Sub "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:yourSnsTopicName"
defaultErrorResponse(err, event, context, callback)
Default error handling function. Returns Internal Server Error response.
Also, log objects that have properties of event
anderr
.
License
MIT