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

simplify error make #5883

Merged
merged 1 commit into from
Jul 2, 2022
Merged

simplify error make #5883

merged 1 commit into from
Jul 2, 2022

Conversation

WindSoilder
Copy link
Collaborator

@WindSoilder WindSoilder commented Jun 26, 2022

Description

Fixes: #5878

The simplest fix is just make error_make always returns Result::Err.

Breaking changes

I found that error_make is supporting pipeline input, which makes harder to adjust $env.LAST_STATUS_CODE to 1, to achieve this, we need to consider output result from table command, or make changes in eval_block.

More importantly, it's hard to make a decision if we get the following output value:

  1. Value::Error(..)
  2. [Value::Int(..), Value::Error(..), Value::Int(..)]
  3. [Value::Error(..), Value::Error(..)]

Should nu think the result is success or not?

So I remove pipeline input support for error_make, and make error_struct from optional to required.

Tests

Make sure you've done the following:

  • Add tests that cover your changes, either in the command examples, the crate/tests folder, or in the /tests folder.
  • Try to think about corner cases and various ways how your changes could break. Cover them with tests.
  • If adding tests is not possible, please document in the PR body a minimal example with steps on how to reproduce so one can verify your change works.

Make sure you've run and fixed any issues with these commands:

  • cargo fmt --all -- --check to check standard code formatting (cargo fmt --all applies these changes)
  • cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace --features=extra to check that all the tests pass

@fdncred
Copy link
Collaborator

fdncred commented Jul 1, 2022

I've looked at this several times and I'm worried about how much code has been removed. This may be the perfect change, or maybe not. I'm not sure yet.

@WindSoilder
Copy link
Collaborator Author

WindSoilder commented Jul 2, 2022

Thanks for your feedback, I understand your concern, but I think it's fine, as long as error make doesn't pipeline input

@fdncred
Copy link
Collaborator

fdncred commented Jul 2, 2022

We can always revert if we need to. Thanks.

@fdncred fdncred merged commit 79da470 into nushell:main Jul 2, 2022
@WindSoilder WindSoilder deleted the error_make branch October 12, 2022 13:41
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

Successfully merging this pull request may close these issues.

error make neither stops the script nor even change the exit code
2 participants