You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[wasm] Attempting to get an EventWriter for an unregistered event type panics with an unhelpful message #2139
The application is misconfigured so I expect this to panic, and ideally the message for the panic would explain that a system attempted to fetch an EventWriter for an unregistered event type.
FYI you don't need to register the event with add_event, merely create a resource for it.
Adding the resource would remove this particular error, but the event would not be functioning without the managing system (added e.g. via add_event), would it?
Since events are used a lot, could we maybe make this a custom error pointing to add_event? On Linux I just get "thread 'main' panicked at 'Requested resource does not exist: bevy_app::event::Eventsstream::Event'" which could be nicer in my opinion if it were more event specific.
Adding the resource would remove this particular error, but the event would not be functioning without the managing system (added e.g. via add_event), would it?
It will work just fine, it'll just lack automatic cleanup. This pattern is actually quite useful for when you need events to function for systems that sleep (like if they operate on a fixed time step); you just need to handle cleaning them up on your own so the memory use doesn't grow in an unbounded fashion.
I'm working on an EventConsumer API over in #2116 to make that more ergonomic and better documented. It'll probably get split out into a separate PR for scope though.
Since events are used a lot, could we maybe make this a custom error pointing to add_event? On Linux I just get "thread 'main' panicked at 'Requested resource does not exist: bevy_app::event::Eventsstream::Event'" which could be nicer in my opinion if it were more event specific.
Agreed, although it should also point to .init_resource::<T> as well.
Activity
alice-i-cecile commentedon May 10, 2021
FYI you don't need to register the event with add_event, merely create a resource for it. I agree that the error message should be much better though.
NiklasEi commentedon May 10, 2021
Adding the resource would remove this particular error, but the event would not be functioning without the managing system (added e.g. via
add_event), would it?Since events are used a lot, could we maybe make this a custom error pointing to
add_event? On Linux I just get "thread 'main' panicked at 'Requested resource does not exist: bevy_app::event::Eventsstream::Event'" which could be nicer in my opinion if it were more event specific.alice-i-cecile commentedon May 10, 2021
It will work just fine, it'll just lack automatic cleanup. This pattern is actually quite useful for when you need events to function for systems that sleep (like if they operate on a fixed time step); you just need to handle cleaning them up on your own so the memory use doesn't grow in an unbounded fashion.
I'm working on an
EventConsumerAPI over in #2116 to make that more ergonomic and better documented. It'll probably get split out into a separate PR for scope though.Agreed, although it should also point to
.init_resource::<T>as well.alice-i-cecile commentedon Dec 12, 2021
Cleaning up the error messages here would be a nice step forward, and should be quite approachable for a new contributor.
CGMossa commentedon Jun 30, 2022
I recommend we close this;
A similar issue is #5088, and it was decided there to close.