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

Catalog and catch the main proc macro usage error before it blows up in the compilation of the macro #154

Closed
gbin opened this issue Dec 16, 2024 · 3 comments · Fixed by #212

Comments

@gbin
Copy link
Collaborator

gbin commented Dec 16, 2024

Today if the user makes a mistake in the config for example, it doesn't compile the macro so the error is always on the macro invocation and totally dependent on what the macro is trying to compile from the broken input.

@AS1100K
Copy link
Contributor

AS1100K commented Jan 9, 2025

As what I understood from this is that this issue is about improving error handling

The current error when wrong file name is provided to gen_cumsgs macro

error: proc macro panicked
 --> examples/cu_caterpillar/src/logreader.rs:4:1
  |
4 | gen_cumsgs!("invalid/copperconfig.ron");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: message: Failed to read configuration file: /home/as1100k/developer/copper-rs/examples/cu_caterpillar/invalid/copperconfig.ron

to this improved version Code

error: The configuration file `invalid/copperconfig.ron` does not exist. Please provide a valid path.
 --> examples/cu_caterpillar/src/logreader.rs:4:1
  |
4 | gen_cumsgs!("invalid/copperconfig.ron");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `gen_cumsgs` (in Nightly builds, run with -Z macro-backtrace for more info)

This aligns with my understanding of the issue, but I wanted to confirm if this interpretation matches your intent. If not, could you provide some guidance or clarification to help me understand what you’re aiming for?

@gbin
Copy link
Collaborator Author

gbin commented Jan 9, 2025

@AS1100K yes this is a good start, we could merge this one as part 1 ie. invalid path or invalid RON syntax.
The part of the cataloging revolves around understanding all the failure modes too: for example, if I put a non existent message type in the config, or a non existent Task type.
also if I put a non existent id in a connection ...
If we could start to make a list and a test suite that would be amazing.

We can start to fix the obvious stuff first and then iterate.

another huge improvement we could do: Do you think also we can report a line in the RON files where the error is?

@AS1100K
Copy link
Contributor

AS1100K commented Jan 10, 2025

another huge improvement we could do: Do you think also we can report a line in the RON files where the error is?

That a great Idea, In PR #212, I have added this. Also, @gbin do you think we should also have a link to the RON file that will open the file at the position of error.

@gbin gbin closed this as completed in #212 Jan 12, 2025
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 a pull request may close this issue.

2 participants