errors

package
v0.0.0-...-2588412 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package errors provides a boundary error type to be returned by cmds executed within the AWS Lambda environment.

See the Lambda Go integration library: https://github.com/aws/aws-lambda-go/

The Lambda Go integration library wraps a Function error's string representation in its own error type, so in order to preserve the original error structure the we use a JSON string as our Error type's string representation, resulting in a JSON within JSON response payload. https://github.com/aws/aws-lambda-go/blob/master/lambda/messages/messages.go#L32

In cases where the Lambda is used as an API Gateway integration this allows us to deserialise our JSON string in a response mapping template and extract the error code, public message and private message separately.

Index

Constants

View Source
const (
	// CodeApplicationError is a catch-all for internal errors.
	// API Gateway mapping:     500 Internal server error
	CodeApplicationError = "APPLICATION_ERROR"

	// CodeAccessDenied represents an authorization error.
	// API Gateway mapping:     403 forbidden
	CodeAccessDenied = "ACCESS_DENIED"

	// CodeBadInput represents a bad Lambda input error.
	// API Gateway mapping:     400 Bad request
	CodeBadInput = "BAD_INPUT"

	// CodeInvalidInput represents a bad Lambda input value error.
	// API Gateway mapping:     422 Unprocessable entity
	CodeInvalidInput = "INVALID_INPUT"
)

Generic error codes for errors returned by a Lambda function. The code can be used by API Gateway to reliably map an error response.

Variables

This section is empty.

Functions

func WithCode

func WithCode(err error, code string) error

WithCode returns a Lambda error for the original error with a specified code and derives the message from the code. If there's no message defined for the code the public message will be empty.

func Wrap

func Wrap(err error, code, msg string) error

Wrap returns a Lambda error for the original error with a specified code and message.

func Wrapf

func Wrapf(err error, code, format string, args ...interface{}) error

Wrapf returns a Lambda error for the original error with a specified code and string format.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL