jhuapl-boss / heaviside

Python library and DSL for working with AWS StepFunctions
Apache License 2.0
35 stars 10 forks source link

How to catch Lambda error and jump another State ? #9

Closed hangingman closed 5 years ago

hangingman commented 5 years ago

Hi,

I would like to catch Errors on Lambda, then jump to the another previous State. I tried following DSL:

    Pass()
        """check_something"""

    Lambda('xxxx')
        """some_my_func"""
        timeout: 60
        heartbeat: 30
        input: '$'
        output: '$'
        catch []:
            """check_something"""

But, it causes error. Is there any suggestion ?

derek-pryor commented 5 years ago

Including the error output would be helpful in the future. The error message is saying that a comment is not valid at that location. If you read the DSL definition for the Lambda state it says that you need a State, not a comment in the catch block.


File "issue.hsd", line 11
        """check_something"""
        ^
Syntax Error: Invalid syntax
derek-pryor commented 5 years ago

Currently Heaviside doesn't support arbitrary state transitions (even though AWS Step Functions do). I've tried to create the most common control flow statements in the Heaviside DSL so that files written in the DSL are easier to follow and to shy away from goto style programming.

If your control flow needs are not satisfied by the existing statements something new could be added (either a new control flow structure or just added goto support).

hangingman commented 5 years ago

@derek-pryor Hi, thank you for your explanation ! I expected the """xxx""" represent the kind of label on the general programming language. And, I was suffered from lack of function(state transition). But, it seems heaviside's policy. My question would be useful for the people of later.

derek-pryor commented 5 years ago

The """xxx""" does label / name the state (instead of the state being called LineXX), but cannot be used to create a transition. I am starting to plan for another release of Heaviside and may include a new control flow or goto ability.

derek-pryor commented 5 years ago

I just created PR #11 that adds this support. I'll be creating the next Heaviside release in a bit after I add some other improvements.

derek-pryor commented 5 years ago

@hangingman Heaviside 2.0 was just pushed to PyPi and contains this fix