Skip to content

RafalWilinski/serverless-lambda-throw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Lambda Error

serverless

Normally, throwing unhandled new Error inside AWS Lambda environment tied to API Gateway results in 500 - Internal Server Error.

This module solves that problem by wrapping your Error into API Gateway compatible response format.

Installation

npm install serverless-lambda-throw --save

Usage

const LambdaError = require('serverless-lambda-throw');

module.exports.hello = (event, context, callback) => {
  LambdaError(callback); // registers error handler

  throw new Error('Uncaught error thrown!'); // Responds with 400 and wrapped error into API Gateway compatible format
};

About

Safely throw Errors in AWS API Gateway connected Lambdas

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages