add position to scene errors#8065
Conversation
Co-authored-by: Paul Hansen <[email protected]>
6cd8245 to
2344418
Compare
| .deserialize(&mut deserializer) | ||
| .map_err(|e| { | ||
| let span_error = deserializer.span_error(e); | ||
| anyhow!( |
There was a problem hiding this comment.
I'd really like for us to reduce our use of anyhow. IMO it's a crate that end-users should be using, not the libraries they're depending on. With that said, this isn't a breaking change from what we're already doing, so I won't block on this.
There was a problem hiding this comment.
Yeah I was just using anyhow here because it was already the mechanism being used (The ? was converting it to an anyhow Result). Normally for error handling in libs you would have an error enum that would have variants for the possible failure states and that would hold the context needed to display this error. You would construct that variant here instead. Should be easy enough to migrate this to that if/when we make a switch away from anyhow.
# Objective - Fixes #6760 - adds line and position on line info to scene errors ```text Before: 2023-03-12T22:38:59.103220Z WARN bevy_asset::asset_server: encountered an error while loading an asset: Expected closing `)` After: 2023-03-12T22:38:59.103220Z WARN bevy_asset::asset_server: encountered an error while loading an asset: Expected closing `)` at scenes/test/scene.scn.ron:10:4 ``` ## Solution - use span_error to get position info. This is what the ron crate does internally to get the position info. https://github.com/ron-rs/ron/blob/562963f88733cae0e3ca2a128b590817f0346343/src/options.rs#L158 ## Changelog - added line numbers to scene errors --------- Co-authored-by: Paul Hansen <[email protected]>
Objective
Solution
Changelog