Skip to content

[Feature] Ability to pass failure exit code to the failed block #801

@Ph0enixKM

Description

@Ph0enixKM

Is your feature request related to a problem? Please describe.
Currently we have failed block that runs when a failure has to be handled. We already expose then block which exposes error code under a variable.

$ ... $ then(exit_code) {
  echo exit_code
}

Add ability to do the same for failure block.

Describe the solution you'd like
Ability to run this block of code like this

$ ... $ failed(code) {
  echo code
}

Additional context
This is important because in the handling block we may run multiple other failing expression, thus introducing a necessity to create a failed variable.

// Before
$ ... $ failed {
  let error = status
  trust $ ... $
  echo "Exit code: {error}"
}

// After
$ ... $ failed(error) {
  trust $ ... $
  echo "Exit code: {error}"
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions