Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/barsoosayque/bevy_fallible
A simple plugin to add fallible systems to Bevy game engine
https://github.com/barsoosayque/bevy_fallible
bevy
Last synced: 3 months ago
JSON representation
A simple plugin to add fallible systems to Bevy game engine
- Host: GitHub
- URL: https://github.com/barsoosayque/bevy_fallible
- Owner: barsoosayque
- License: mit
- Created: 2020-11-26T15:03:08.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-04T05:23:38.000Z (7 months ago)
- Last Synced: 2024-09-09T22:38:09.517Z (4 months ago)
- Topics: bevy
- Language: Rust
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
bevy_fallible
=============[![Crates.io](https://img.shields.io/crates/v/bevy_fallible)](https://crates.io/crates/bevy_fallible)
[![Docs.rs](https://docs.rs/bevy_fallible/badge.svg)](https://docs.rs/bevy_fallible)
[![License](https://img.shields.io/crates/l/bevy_fallible)](https://github.com/barsoosayque/bevy_fallible/blob/master/LICENSE)A simple plugin to install fallible systems to bevy
## API
Library provides two main components: `#[fallible_system]` attribute macro and `SystemErrorEvent` struct.
Essentially, every *fallible_system* will generate a `SystemErrorEvent` event if it results in an error, and that's about it.For simplier usage, there is `fallibleSystemPlugin` to register everything you'll need to recieve error events.
## Example
```rust
// Some system that might fail
#[fallible_system]
fn system(asset_server: Res) -> anyhow::Result<()> {
let handle: Handle = asset_server.load("texture")?;
}// Let's make another system to read every event about other
// systems failures and report !
#[derive(Default)]
struct ReportSystemState{ reader: EventReader }
fn report_system(mut state: Local, mut events: ResMut>) {
for event in state.reader.iter(&mut events) {
println!("Error in {}: {}", event.system_name, event.error);
}
}fn main() {
App::build()
.add_plugin(fallibleSystemPlugin)
.add_startup_system(system.system())
.add_system(report_system.system())
.run();
}
```