Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 653 Bytes

File metadata and controls

31 lines (23 loc) · 653 Bytes

AWS Lambda function errors in Go

You can create custom error handling to raise an exception directly from your Lambda function and handle it directly.

The following code samples demonstrate how to do this. Note that custom errors in Go must import the errors module.

package main
 
import (
        "errors"
        "github.com/aws/aws-lambda-go/lambda"
)
 
func OnlyErrors() error {
        return errors.New("something went wrong!")
}
 
func main() {
        lambda.Start(OnlyErrors)
}

Which returns the following:

{
  "errorMessage": "something went wrong!",
  "errorType": "errorString"
}