Amethyst: Remove all `expect` and `unwrap` from source (where reasonable)

Created on 24 Aug 2017  路  5Comments  路  Source: amethyst/amethyst

Right now when the engine isn't used exactly the way it's supposed to, it will often just leave the user with something along the lines of thread 'main' panicked at 'called 'Option::unwrap()' on a 'None' value'. Often enough, this happens in a thread other than main, so the end user cannot even use the back trace to figure out what he did that went wrong.

It makes more sense to return a Result at all places, only using except where it is believed an error should be impossible.

To make this easier, we can move to the error-chain crate, to reduce the amount of boilerplate such a comprehensive result system would require.

easy good first issue important ready

All 5 comments

I'm gonna have a look at this, since I'm an error-chain evangelist :P

I've implemented error handling using error-chain in #332 , just for the renderer so far.

@Binero I'm improving errors currently, and I remember you had such an issue while refactoring your code to use the latest version of Amethyst. Can you remember at which line the engine panicked?

@torkleyy IIRC the renderer expected a Camerawhen there wasn't any. It might also be worth logging to the console when a Camera doesn't have a Transform.

I feel the main thrust of this issue has been accomplished pretty satisfactorily. So I'm going to close this. Let me know if you disagree with my decision.

Was this page helpful?
0 / 5 - 0 ratings