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

arduino-hal: Add panic-halt feature #594

Closed
wants to merge 1 commit into from
Closed

Conversation

Hqnnqh
Copy link

@Hqnnqh Hqnnqh commented Oct 26, 2024

For most beginners, the panic handler will be a simple one. Like the one from the panic-halt crate. It's usage has already been established in most exmaples.

Thus, it would be less boilerplate for beginner projects, if the panic-halt handler would just be a feature. Similar to how the uefi-rs crate handles this.

@Rahix
Copy link
Owner

Rahix commented Oct 27, 2024

I am quite torn about doing this. Yes, it is less boilerplate but on the other side it hides essential parts of a bare-metal rust program.

Users will quickly run into situations where they will want a more complex panic handler to get notice of their code crashing. And all online docs will tell them to replace their default panic handler with a custom one.

If the default panic handler gets hidden behind another layer of crate indirection, this will be more difficult to grasp than having the very explicit use panic_halt as _; line right there, in the code.

In general, I am very wary of hiding complexity from the downstream user. Yes, it may make things easier in the beginning, but it creates friction later on when the complexity surfaces in one way or another...


That said, if we can write a general purpose debugging panic handler (e.g. one that prints to the default serial after it was configured), making that available via optional feature would indeed be quite nice.

@Hqnnqh
Copy link
Author

Hqnnqh commented Oct 27, 2024

That makes sense, maybe I'll look into a proper debugging panic handler :)

@Rahix
Copy link
Owner

Rahix commented Nov 1, 2024

I created issue #596 to track addition of such a debugging panic handler. I also wrote down some of my thoughts on the design there. Feel free to discuss and/or ask questions :)

@Rahix Rahix closed this Nov 1, 2024
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.

2 participants