Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Support for custom error types #12

Closed
advdv opened this issue Mar 18, 2017 · 3 comments
Closed

Support for custom error types #12

advdv opened this issue Mar 18, 2017 · 3 comments

Comments

@advdv
Copy link

advdv commented Mar 18, 2017

This might be a long shot but on the 16th of march a feature was added to AWS Step Functions that allows you to drive state transitions based on specific errors from your Lambda functions; a feature I was waiting for. A NodeJS example of this can be found here: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-handling-error-conditions.html and the announcement here https://aws.amazon.com/about-aws/whats-new/2017/03/aws-step-functions-adds-customized-error-handling-for-aws-lambda-functions/

They didn't add matching based on JSON fields or string matching and only check the error type as returned by the runtime. With the awesome wrapper Go you guys made it currently doesn't seem possible (https://github.com/eawsy/aws-lambda-go-shim/blob/81ecb522e11dbd6096b6219fa66d9992e3410b1f/src/proxy.py#L48) to use this feature, is this correct? Is there any way of adding this?

You guys rock! Cheers, Ad

@fsenart
Copy link
Contributor

fsenart commented Mar 18, 2017

@advanderveer ok ok. I think I got it. I've made a simple poc and see how to do the job. Let me one day or two ;)

PS: Thx very much for your issue, I think this new feature can bring the shim to a new level.

fsenart added a commit that referenced this issue Mar 23, 2017
This new feature opens the ability to leverage the new custom error
handling addition to AWS Step Functions.

CAT: #feat
REF: #12
@fsenart
Copy link
Contributor

fsenart commented Mar 23, 2017

@advanderveer sorry for the delay, I was very busy. Update your docker image and that's is, you can return custom errors and use it in step functions:

package main

import (
	"encoding/json"

	"github.com/eawsy/aws-lambda-go-core/service/lambda/runtime"
)

type CustomError struct {
	s string
}

func (e *CustomError) Error() string {
	return e.s
}

func Handle(json.RawMessage, *runtime.Context) (interface{}, error) {
	return nil, &CustomError{"something bad happened"}
}

@fsenart fsenart closed this as completed Mar 23, 2017
@advdv
Copy link
Author

advdv commented Mar 23, 2017

Awesome! Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants