Skip to content

Catalog and catch the main proc macro usage error#212

Merged
gbin merged 3 commits intocopper-project:masterfrom
as1100k-forks:issue-154
Jan 12, 2025
Merged

Catalog and catch the main proc macro usage error#212
gbin merged 3 commits intocopper-project:masterfrom
as1100k-forks:issue-154

Conversation

@AS1100K
Copy link
Copy Markdown
Contributor

@AS1100K AS1100K commented Jan 10, 2025

Fixes #154

This PR also makes error with RON files much helpful as it not shows, where the error. The following is the error message generated with mistake in RON file

error: proc macro panicked
 --> examples/cu_caterpillar/src/logreader.rs:4:1
  |
4 | gen_cumsgs!("copperconfig.ron");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: message: Syntax Error in config: Expected string at position 4:17

@gbin
Copy link
Copy Markdown
Collaborator

gbin commented Jan 10, 2025

Oh yes way better!

Can you add some unit tests so we can see what types of errors it catches?

Thanks

@AS1100K AS1100K changed the title Catalog and catch the main proc macro usage error WIP Catalog and catch the main proc macro usage error Jan 11, 2025
@AS1100K
Copy link
Copy Markdown
Contributor Author

AS1100K commented Jan 11, 2025

I have added catalog of error which came to my mind and added them in tests/compile_fail directory.

Also, currently the error in the RON file is shown with line and column position only when it is an syntax error and in order to identify that a certain type exists in the RON file and in the crate would be much difficult but is possible by validating RON file in build.rs, atm I am thinking of using rustdoc-json could address this. But I believe this would be too much.

@gbin What are you thoughts on this PR?

@AS1100K AS1100K changed the title WIP Catalog and catch the main proc macro usage error Catalog and catch the main proc macro usage error Jan 11, 2025
@gbin
Copy link
Copy Markdown
Collaborator

gbin commented Jan 12, 2025

@AS1100K this is awesome! We will see if the users encounter new cases but this is a really good start.

@gbin gbin merged commit 29f3b9c into copper-project:master Jan 12, 2025
@AS1100K AS1100K deleted the issue-154 branch January 12, 2025 03:47
@makeecat makeecat added the bug Something isn't working label Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants