Enable error returning from `FromReflect` trait
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
When dealing with `FromReflect` implementation other than `derive`, it's hard to know where the error is, since if you have a big tree of nested `dyn Reflect` objects, any of them may fail and return `None`.
## What solution would you like?
One of those:
1. Add a new method `try_from_reflect` which does the actual parsing and change `from_reflect` to a default impl which just call `try_from_reflect` and convert `Result` into `Option`;
2. Modify `from_reflect` to return a `Result` instead of `Option`;
I prefer 1, since it doesn't introduce a braking change for those which already uses `from_reflect`, but will break for any manual `FromReflect` impl, which I think will be fewer use cases.
## What alternative(s) have you considered?
Relying on `panic` or `error` messages for any manual `FromReflect` impl
## Additional context
If there is a consensus about this feature, I can impl it
Contributor guide
Assessment
This issue has not been assessed yet.