-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Nward/commands error handling #11184
base: main
Are you sure you want to change the base?
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
The generated |
The generated |
1 similar comment
The generated |
This's anecdotal, but I've hit spurious panics in several bevy jam 4 entries and this could help remedy some of those cases (the rest would probly be handled by relations 🌈🤞), so this would be nice. That being said, should the default behaviour change from panicking to logging? I think I'm in favour of that approach, but would it be possible to make that configurable for those that would like to default to panicking? |
@SecretPocketCat There's an issue tracking commands needing to be infallible whenever possible here. General consensus seems to be that it's needed - just needs to be implemented. |
@SecretPocketCat I actually took this issue because I was getting hit with that exact problem when developing my game for the bevy jam and now with my current project, on both occasions I tried to debug extensively but couldn't find where the multiple despawns happened and it was irritating, it feels like you get no control over your program. I believe that crates should never panic and give the user the ability to decide what to do with the error, after all Rust already has great support for You raise a good point about making the default behavior configurable, as @dmyyy noted it was already discussed in the issue and in the previous PR. I suggest maybe adding a feature flag that will allow to change the default behavior back to panic, what do you think? I also see that the |
In the How to run benchmarks
If your system has a tendency to thermally throttle (i.e. using a laptop), you may need to do something like fixing your cpu clocks to the base clock speed and/or use eco mode to reduce noise. |
Sounds reasonable, but maybe I was bringing up smt. that should be just a follow-up PR instead. |
The generated |
The generated |
Sorry, I thought I commited those changes. Added them now. Thank you for the support :) |
I ran the tests locally a few times (I did |
For some reason there's some difference between the errors in CI and some platforms. You should just use the error messages that CI has and accept that your local compile fail tests are going to fail. |
Good to know! I reverted the change and the CI seems to run fine now |
@hymm Did you get a chance to run the benchmark yourself? |
Going to try and do it today. I ran them before without the new benches and was seeing a regression on fake commands. I'll post my results in a bit. |
Looking forward to seeing the results, thank you! ⭐ |
If there's any changes it's pretty much in the noise. Ran them on main and this pr 3 times each. Depending on which run one could be faster than the other, but all the runs were in the same range. Good to see that making the error handler configurable didn't slow things down.
|
Yes! I'm very happy to see that, thank you for the thorough benchmarking :) |
Needs 2 approvals from ECS-SME's, since this is controversial. Community approval can be helpful too. I'm not an ECS-SME, but I'll try to review sometime in the next couple weeks. |
Oh good to know, I look forward for your review :) |
Sorry for not noticing this! I will get to this in the 0.15 cycle: this is important and valuable work that I think we can build on. Not a good last minute addition though, so I'm cutting from the 0.14 milestone. |
Hi @EngoDev! Just checking in, any chance you could update your branch, I know it's been awhile 🙂 might make it easier to get some reviewin' eyes on it. |
Of course! Thank you, I'll get on it today |
Objective
Fixes: #2004
Original PR: #2241
Thank you very much @NathanSWard for all your hard work! ⭐ I mostly just updated their code to work with the current version of bevy.
Also this is my first bevy PR, feedback is very much appreciated :)
Changelog
Added
FallibleCommand
CommandErrorHandling
CommandErrorHandler
ignore
panic
log
- This is the default behavior instead ofpanic
. The error will be logged viaerror!
.Changed
If a command is fallible, then new return type is a
Config
type.The
Config
type allows a user to optionally provide an error handler viaon_err
.Example