Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

Improve errors and error handling #460

Closed
torkleyy opened this issue Oct 26, 2017 · 21 comments
Closed

Improve errors and error handling #460

torkleyy opened this issue Oct 26, 2017 · 21 comments
Labels
diff: easy Achievable by a single junior developer with a bit of guidance. pri: normal An issue that is causing a noticeable impact, but can be worked around type: improvement An improvement or change to an existing feature.
Milestone

Comments

@torkleyy
Copy link
Member

torkleyy commented Oct 26, 2017

So we need

  • more error types
  • include more information
  • allow better handling of them (e.g. improve amethyst_assets::Progress stuff)

There are many locations where such improvements can be made, so I'm gonna set this to easy and ask for help here. Small PRs are preferred here.

@torkleyy torkleyy added diff: easy Achievable by a single junior developer with a bit of guidance. good first issue This is a good issue to start with if you are new and want to contribute to Amethyst. note: help wanted pri: normal An issue that is causing a noticeable impact, but can be worked around type: improvement An improvement or change to an existing feature. labels Oct 26, 2017
@torkleyy
Copy link
Member Author

If there are any questions, I'll gladly assist you!

@minecrawler
Copy link
Contributor

What about logging?

@torkleyy
Copy link
Member Author

We also need logging, should be a separate issue though.

@torkleyy
Copy link
Member Author

I'd suggest to use error_chain for this.

@Rhuagh
Copy link
Member

Rhuagh commented Oct 27, 2017

YES!

@torkleyy
Copy link
Member Author

So I'm working on better error handling in the assets crate now.

@torkleyy
Copy link
Member Author

torkleyy commented Oct 28, 2017

I solved the harder part of this in #464 which introduces much better errors for asset handling. What is left are easier jobs for the other crates:

  • amethyst_gltf
  • amethyst_renderer
  • amethyst

All this crates would benefit from using error_chain!.

@Binero
Copy link
Contributor

Binero commented Nov 10, 2017

This issue is strongly tied to #301.

@Aceeri
Copy link
Member

Aceeri commented Nov 20, 2017

Thoughts on using failure for this?

@Binero
Copy link
Contributor

Binero commented Nov 20, 2017

What are the advantages of said crate? It says it tries to solve a lot of problems quick-error and error-chain have, but doesn't go into more detail.

@Hittherhod
Copy link
Contributor

From listening to a talk about failure it seems like error-chain encourages things like a single unified error type for a library as well as having a steep learning curve for newcomers (macros given pretty bad error messages if you mess them up).

@zakarumych
Copy link
Member

@Hittherhod. From my experience you easily can define multiple error_chains in crate and establish links between them to use ?. Or use chain_err function to stack up errors for better context of what went bad where you handle errors.

@Rhuagh
Copy link
Member

Rhuagh commented Dec 29, 2017

I'm in favor of moving to failure myself.

@Binero
Copy link
Contributor

Binero commented Dec 30, 2017

One major setback in using the failure crate is that it's very hard to maintain type information about the errors you're returning, when there is a series of possible errors. This is especially painful when some error variants are from external libraries, as as far as I know there is no way to implement foreign errors like in error-chain.

Furthermore, much like in error chain, I don't think there is an easy way to chain errors without losing type information.

@torkleyy torkleyy added status: discussing and removed good first issue This is a good issue to start with if you are new and want to contribute to Amethyst. status: ready labels Mar 25, 2018
@AnneKitsune
Copy link
Contributor

for reference https://github.com/rust-lang-nursery/failure

Where do we go from here? failure vs error_chain vs ??

@AnneKitsune AnneKitsune added this to the 1.0 milestone Aug 13, 2018
@OvermindDL1
Copy link

For note:
rust-lang-deprecated/failure#181

@anderejd
Copy link
Contributor

Where do we go from here? failure vs error_chain vs ??

It doesn't need to be a library, we can use the standard built-in error handling in rust, using .map_err and From impls. This is my preference.

@OvermindDL1
Copy link

Even if Failure is used it is still recommended to make your own error enum and don't use the generic Error as that one is designed only for generic setup and testing, not for actual publication. The rest of the stuff in Failure is still very useful.

@distransient
Copy link
Member

While working through dealing with some of the unwrap's on my own branch, I found some of the error types to be strange (like PrefabError being a re-export of the Specs error type). I did some looking at Failure and with how complicated of a system Amethyst is, it definitely seems like it'd benefit from how clean the api is for that. I could start working on implementing this for parts of the API like amethyst_animation if people would still like for this to be the way forward.

@distransient
Copy link
Member

Actually, it appears that we should probably wait for the work and effects of RFC 2504 (rust-lang/rust#53487) to settle, since it'll likely effect the api of Failure and best path forward generally. Although it's regardless error-chain will be deprecated, it'd still make our lives easier to wait just a little longer on changing our Error strategy 😛

@torkleyy
Copy link
Member Author

This issue is no longer of value. We have an error strategy by now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
diff: easy Achievable by a single junior developer with a bit of guidance. pri: normal An issue that is causing a noticeable impact, but can be worked around type: improvement An improvement or change to an existing feature.
Projects
None yet
Development

No branches or pull requests