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

[P4Testgen] Better error handling in the test backends. #4403

Open
fruffy opened this issue Feb 8, 2024 · 2 comments
Open

[P4Testgen] Better error handling in the test backends. #4403

fruffy opened this issue Feb 8, 2024 · 2 comments
Assignees
Labels
p4tools Topics related to the P4Tools back end

Comments

@fruffy
Copy link
Collaborator

fruffy commented Feb 8, 2024

Improve the error handling in the test back ends. Instead of throwing exceptions everywhere, try to gracefully handle errors and bubble them upwards. Considering using a utility macro for that.

Originally posted by @vlstill in #4372 (comment)

@fruffy fruffy self-assigned this Feb 8, 2024
@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Feb 8, 2024
@vlstill
Copy link
Contributor

vlstill commented Feb 9, 2024

Considering using a utility macro for that.

I would be quite weary of macros, especially like the one you suggested that contains return.

Something like https://github.com/TartanLlama/optional could be better, but I would strongly prefer something that matches the names C++23 gives these functions (sadly C++23 is far away, we currently support GCC 9 and would need GCC 12+ to have these functions). I am little afraid it would lead to lambda mess, but in many cases it could probably work. When we would introduce a lib for such things, something akin to std::expected would be probably better than better optional.

@fruffy
Copy link
Collaborator Author

fruffy commented Feb 9, 2024

I would be quite weary of macros, especially like the one you suggested that contains return.

It would effectively be the same as the Protobuf status macros, which are used extensively for Abseil code: https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/stubs/status_macros.h

I also would prefer the TartanLlama optional, especially because it also includes optional reference support, which is not coming to C++ any time soon. For expected expected-lite can be used because it has the same interface. But it does not come with the same kind of convenience functions the TartanLlama expected provides.

I could try incubating any of these on the P4Testgen side at least and then eventually contribute to the wider compiler infrastructure if it works out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4tools Topics related to the P4Tools back end
Projects
None yet
Development

No branches or pull requests

2 participants