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

rethrow primop #8689

Open
roberth opened this issue Jul 11, 2023 · 5 comments
Open

rethrow primop #8689

roberth opened this issue Jul 11, 2023 · 5 comments
Labels
error-messages Confusing messages and better diagnostics feature Feature request or proposal idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. language The Nix expression language; parser, interpreter, primops, evaluation, etc

Comments

@roberth
Copy link
Member

roberth commented Jul 11, 2023

Is your feature request related to a problem? Please describe.

The error message can not be touched

However, in many cases, users just want to add some info to the message.

In other cases, they may want to combine messages.

Both can be done without making evaluation order dependent.

Describe the solution you'd like

builtins.rethrow such that

builtins.rethrow
  { a = "one"; b = throw "foo"; c = throw "bar"; }
  ({ a ? null, b, c }:
    assert a == null;
    "Errors are ${b} and ${c}"
  )
  v

causes the error

error: Errors are foo and bar

If they care about the value when successful, they can use a let binding to retrieve it.

Describe alternatives you've considered

Additional context

Priorities

Add 👍 to issues you find important.

@roberth roberth added feature Feature request or proposal error-messages Confusing messages and better diagnostics language The Nix expression language; parser, interpreter, primops, evaluation, etc labels Jul 11, 2023
@roberth
Copy link
Member Author

roberth commented Aug 3, 2023

How should the stack trace behave?
It could be made similarly "first class":

withTrace (trace: msg: ...) v

@thufschmitt thufschmitt moved this to ⚖ To discuss in Nix team Aug 9, 2023
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-07-31-nix-team-meeting-minutes-76/31486/1

@thufschmitt thufschmitt added the idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. label Sep 22, 2023
@thufschmitt thufschmitt moved this from ⚖ To discuss to Post meeting action in Nix team Sep 22, 2023
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-09-22-nix-team-meeting-minutes-88/33343/1

@infinisil
Copy link
Member

I remember talking with Robert about how the proposed rethrow here doesn't entirely work out as described, though that something like it should work. So I don't think it should be blindly implemented as shown here, but rather someone should spend some time to think about how exactly it should work first. Just as a note to anybody wanting to go for this.

Since this isn't a high-priority feature, I won't be attempting this myself for now though (and I hope Robert won't either), there's better things to focus on imo :)

@fricklerhandwerk
Copy link
Contributor

Triaged in Nix team meeting 2023-09-22:

idea approved to add as experimental feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-messages Confusing messages and better diagnostics feature Feature request or proposal idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. language The Nix expression language; parser, interpreter, primops, evaluation, etc
Projects
None yet
Development

No branches or pull requests

5 participants