lambda-error
v0.0.6
Published
Error objects in AWS Lambda for response mapping in AWS API Gateway
Downloads
22
Readme
AWS Lambda Error
If you plan to use Node.js in an AWS Lambda function with an AWS API Gateway and need to have streamlined error objects for easy response parsing, just use lambda-error
:
var lambdaErr = require('lambda-error');
exports.handle = function(e, ctx, callback) {
if (!e.name) {
return callback(
lambdaErr.BadRequest('Missing name').toString()
);
}
ctx.succeed({name: e.name, found: true});
};
var lambdaErr = require('lambda-error');
exports.handle = function(e, ctx, callback) {
if (!e.name) {
return callback(
lambdaErr.BadRequest('Missing name').withContext(ctx).toString()
);
}
ctx.succeed({name: e.name, found: true});
};
Available error codes
BadRequest
(400)Forbidden
(403)NotFound
(404)Conflict
(409)InternalServerError
(500)