Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail section #397

Open
k2tzumi opened this issue Feb 2, 2023 · 3 comments
Open

Fail section #397

k2tzumi opened this issue Feb 2, 2023 · 3 comments

Comments

@k2tzumi
Copy link
Collaborator

k2tzumi commented Feb 2, 2023

What is this?

Fail section that always fails when described.

Use Cases

This is when you want to make a scenario fail after some operation in a later step when you already know that the previous step failed.

A more concrete example would be an API call that results in a 500 error and you want to display the application log.

  • example
    steps:
      -
        req:
          desc: Some kind of error occurs. Errors are not evaluated here.
          /fail-end-point:
            get:
              body: null
      -
        desc: Handling errors
        if: previous.res.status == 500
        exec:
          command: tail -10 /var/log/error.log
        # Whenever there is a FAIL section, it fails and does not evaluate the subsequent steps.
        fail: 'Fail messages.'
@k2tzumi
Copy link
Collaborator Author

k2tzumi commented Feb 2, 2023

I can do the following, but I would like to display the appropriate message

steps:
  -
    req:
      desc: Some kind of error occurs. Errors are not evaluated here.
      /fail-end-point:
        get:
          body: null
  -
    desc: Handling errors
    if: previous.res.status == 500
    exec:
      command: tail -10 /var/log/error.log
    test: false

@k1LoW
Copy link
Owner

k1LoW commented Feb 3, 2023

I probably understand what you want to do.
However, I feel that the proposed API is not easy to use.

u-m...

@k2tzumi
Copy link
Collaborator Author

k2tzumi commented Feb 4, 2023

However, I feel that the proposed API is not easy to use.

Would it be better to have fine control like the error functions in the testing package?

  • Fail
  • FailNow or Fatal

Or maybe extend the test section so that it can be handled by onError.
We'll need to have a deeper discussion about the impact on other functions. 😄

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

No branches or pull requests

2 participants