-
-
Notifications
You must be signed in to change notification settings - Fork 748
Support causes in amethyst::Error #1214
Comments
Hm, yeah. The errors ecosystem is a bit of a clustertruck right now and I could have dug deeper into the existing discussions. @torkleyy So if I've read things correctly, the status quo is that someone should write an RFC? |
I'd personally just go with |
@amethyst/engine-devs please comment whether you'd like an RFC. |
I'm happy with going with |
I would like to stay away from failure because in its current state its deprecated. I say we punt on this issue till rust has settled on a proper backtrace type. There are two big areas that need to be addressed before I say we move forward. One is waiting for |
Can you provide any references for its deprecation?
…On Tue, Dec 4, 2018, 18:53 Lucio Franco ***@***.*** wrote:
I would like to stay away from failure because in its current state its
deprecated. I say we punt on this issue till rust has settled on a proper
backtrace type.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1214 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AWFFuUwL4FHQbMNhlbu5vbCYDfvEI6Q0ks5u1raagaJpZM4ZA8fO>
.
|
|
Is the error handling a large enough issue right now to warrant two rewrites to go to current- |
Really, error handling is a Takes off my @fhaynes hat |
I don't consider that a deprecation. My only motivation is to settle on something for now, even if it's not perfect. I don't see this important enough to make a big discussion about it right now though, so I'm also fine with leaving things as they are. |
@torkleyy what do you mean you don't consider it a depreciation? The failures team literally describes it like that. I personally, would like to see amethyst move to just error enums, as that is the most lightweight way to handle errors right now. Then move to the std error trait later. |
Circling back this is the big issue we should be following rust-lang/rust#53487 |
That's pretty much what |
Right, but I say we hold off on touching any error handling for now. Wait, till rust has it stabilized. I don't even think we should invest our time into it until backtraces are in and stabilized. |
I think Amethyst both short and long term can maintain its own It would implement EDIT: I have done something like that in reproto, minus implementing |
So related to the RFC https://github.com/rust-lang/rfcs/blob/master/text/2504-fix-error.md#how-this-impacts-failure do you think its worth it to implement everything based on That said too, backtrace in Mostly, my worries stem from |
@udoprog related to your |
1220: Introduce amethyst_error r=fhaynes a=udoprog Following #1214 This introduces the minimal API necessary to convert existing Error types (some which includes causes). It currently mimics the `failure::Error` API, with methods named according to the ["fix Error" RFC](https://github.com/rust-lang/rfcs/blob/master/text/2504-fix-error.md). That means: * We include the `format_err!` macro and the `ResultExt` trait with an implementation of `with_context` from `failure`. * The error type includes backtraces directly (instead of wrapping it in through e.g. `Context<D>`) in comparison to `failure`. * We include a blanket `From<E> where E: std::error::Error` implementation to convert any type that implements `std::error::Error` into `Error`. * Note: this has the side-effect that this `Error` can't implement `std::error::Error`. * We are using `source` from `std::error::Error` instead of `cause`. * We don't implement `std::error::Error` directly, but we do implement some methods which are similar (`source`). We implement `as_error` to access a reference to the underlying `std::error::Error`. Similarly to how `failure::Error` doesn't implement `Fail` directly but provides `as_fail`. Note that since this RFC is so sparse, there's really not much to implement, and most other methods which are used to actually build errors are local to this crate (e.g. `ResultExt::with_context`). I have a branch where I've tried to apply this crate here: https://github.com/udoprog/amethyst/commit/amethyst-error-full I think I might have accidentally botched some of the `From<T>` implementations, but it should still give an idea of how this type is used. #### Composite APIs Composite APIs are APIs which potentially make use of local error information. Today these tend to lead to "stringy" errors where most of the underlying error information is lost and the errors undergoes a conversion. These are candidates to make use of `amethyst_error::Error` directly right now. The traits I've so far identified that has a tendency to lead to this are: * [`amethyst_assets::Source`](/amethyst/amethyst/blob/master/amethyst_assets/src/source/mod.rs) * [`amethyst_assets::PrefabData`](/amethyst/amethyst/blob/master/amethyst_assets/src/prefab/mod.rs) * [`amethyst_assets::SimpleFormat`](/amethyst/amethyst/blob/master/amethyst_assets/src/asset.rs) * Here's an example where SimpleFormat "stringifies" errors instead of propagating them to work around error constraints: https://github.com/amethyst/amethyst/blob/master/amethyst_ui/src/prefab.rs#L736 * [`amethyst_renderer::Pass/Pipeline` stuff](/amethyst/amethyst/blob/master/amethyst_renderer/src/pipe/pass.rs). Unsure because it spans over to UI and I don't know how "end user" this is. #### Open Discussions * Dropping the `Sync` constraint ([comment](#1220 (comment))). * ~~Either drop `no_std` support or improve it ([comment 1](#1220 (comment)), [comment 2](#1220 (comment) backtrace is no longer optional. Co-authored-by: John-John Tedro <udoprog@tedro.se> Co-authored-by: Thomas Schaller <torkleyy@gmail.com>
1220: Introduce amethyst_error r=omni-viral,torkleyy,LucioFranco a=udoprog Following #1214 This introduces the minimal API necessary to convert existing Error types (some which includes causes). It currently mimics the `failure::Error` API, with methods named according to the ["fix Error" RFC](https://github.com/rust-lang/rfcs/blob/master/text/2504-fix-error.md). That means: * We include the `format_err!` macro and the `ResultExt` trait with an implementation of `with_context` from `failure`. * The error type includes backtraces directly (instead of wrapping it in through e.g. `Context<D>`) in comparison to `failure`. * We include a blanket `From<E> where E: std::error::Error` implementation to convert any type that implements `std::error::Error` into `Error`. * Note: this has the side-effect that this `Error` can't implement `std::error::Error`. * We are using `source` from `std::error::Error` instead of `cause`. * We don't implement `std::error::Error` directly, but we do implement some methods which are similar (`source`). We implement `as_error` to access a reference to the underlying `std::error::Error`. Similarly to how `failure::Error` doesn't implement `Fail` directly but provides `as_fail`. Note that since this RFC is so sparse, there's really not much to implement, and most other methods which are used to actually build errors are local to this crate (e.g. `ResultExt::with_context`). I have a branch where I've tried to apply this crate here: https://github.com/udoprog/amethyst/commit/amethyst-error-full I think I might have accidentally botched some of the `From<T>` implementations, but it should still give an idea of how this type is used. #### Composite APIs Composite APIs are APIs which potentially make use of local error information. Today these tend to lead to "stringy" errors where most of the underlying error information is lost and the errors undergoes a conversion. These are candidates to make use of `amethyst_error::Error` directly right now. The traits I've so far identified that has a tendency to lead to this are: * [`amethyst_assets::Source`](/amethyst/amethyst/blob/master/amethyst_assets/src/source/mod.rs) * [`amethyst_assets::PrefabData`](/amethyst/amethyst/blob/master/amethyst_assets/src/prefab/mod.rs) * [`amethyst_assets::SimpleFormat`](/amethyst/amethyst/blob/master/amethyst_assets/src/asset.rs) * Here's an example where SimpleFormat "stringifies" errors instead of propagating them to work around error constraints: https://github.com/amethyst/amethyst/blob/master/amethyst_ui/src/prefab.rs#L736 * [`amethyst_renderer::Pass/Pipeline` stuff](/amethyst/amethyst/blob/master/amethyst_renderer/src/pipe/pass.rs). Unsure because it spans over to UI and I don't know how "end user" this is. #### Open Discussions * Dropping the `Sync` constraint ([comment](#1220 (comment))). * ~~Either drop `no_std` support or improve it ([comment 1](#1220 (comment)), [comment 2](#1220 (comment) backtrace is no longer optional. Co-authored-by: John-John Tedro <udoprog@tedro.se> Co-authored-by: Thomas Schaller <torkleyy@gmail.com>
1220: Introduce amethyst_error r=omni-viral,torkleyy,LucioFranco a=udoprog Following #1214 This introduces the minimal API necessary to convert existing Error types (some which includes causes). It currently mimics the `failure::Error` API, with methods named according to the ["fix Error" RFC](https://github.com/rust-lang/rfcs/blob/master/text/2504-fix-error.md). That means: * We include the `format_err!` macro and the `ResultExt` trait with an implementation of `with_context` from `failure`. * The error type includes backtraces directly (instead of wrapping it in through e.g. `Context<D>`) in comparison to `failure`. * We include a blanket `From<E> where E: std::error::Error` implementation to convert any type that implements `std::error::Error` into `Error`. * Note: this has the side-effect that this `Error` can't implement `std::error::Error`. * We are using `source` from `std::error::Error` instead of `cause`. * We don't implement `std::error::Error` directly, but we do implement some methods which are similar (`source`). We implement `as_error` to access a reference to the underlying `std::error::Error`. Similarly to how `failure::Error` doesn't implement `Fail` directly but provides `as_fail`. Note that since this RFC is so sparse, there's really not much to implement, and most other methods which are used to actually build errors are local to this crate (e.g. `ResultExt::with_context`). I have a branch where I've tried to apply this crate here: https://github.com/udoprog/amethyst/commit/amethyst-error-full I think I might have accidentally botched some of the `From<T>` implementations, but it should still give an idea of how this type is used. #### Composite APIs Composite APIs are APIs which potentially make use of local error information. Today these tend to lead to "stringy" errors where most of the underlying error information is lost and the errors undergoes a conversion. These are candidates to make use of `amethyst_error::Error` directly right now. The traits I've so far identified that has a tendency to lead to this are: * [`amethyst_assets::Source`](/amethyst/amethyst/blob/master/amethyst_assets/src/source/mod.rs) * [`amethyst_assets::PrefabData`](/amethyst/amethyst/blob/master/amethyst_assets/src/prefab/mod.rs) * [`amethyst_assets::SimpleFormat`](/amethyst/amethyst/blob/master/amethyst_assets/src/asset.rs) * Here's an example where SimpleFormat "stringifies" errors instead of propagating them to work around error constraints: https://github.com/amethyst/amethyst/blob/master/amethyst_ui/src/prefab.rs#L736 * [`amethyst_renderer::Pass/Pipeline` stuff](/amethyst/amethyst/blob/master/amethyst_renderer/src/pipe/pass.rs). Unsure because it spans over to UI and I don't know how "end user" this is. #### Open Discussions * Dropping the `Sync` constraint ([comment](#1220 (comment))). * ~~Either drop `no_std` support or improve it ([comment 1](#1220 (comment)), [comment 2](#1220 (comment) backtrace is no longer optional. Co-authored-by: John-John Tedro <udoprog@tedro.se> Co-authored-by: Thomas Schaller <torkleyy@gmail.com> Co-authored-by: udoprog <udoprog@tedro.se>
1220: Introduce amethyst_error r=omni-viral,torkleyy,LucioFranco a=udoprog Following #1214 This introduces the minimal API necessary to convert existing Error types (some which includes causes). It currently mimics the `failure::Error` API, with methods named according to the ["fix Error" RFC](https://github.com/rust-lang/rfcs/blob/master/text/2504-fix-error.md). That means: * We include the `format_err!` macro and the `ResultExt` trait with an implementation of `with_context` from `failure`. * The error type includes backtraces directly (instead of wrapping it in through e.g. `Context<D>`) in comparison to `failure`. * We include a blanket `From<E> where E: std::error::Error` implementation to convert any type that implements `std::error::Error` into `Error`. * Note: this has the side-effect that this `Error` can't implement `std::error::Error`. * We are using `source` from `std::error::Error` instead of `cause`. * We don't implement `std::error::Error` directly, but we do implement some methods which are similar (`source`). We implement `as_error` to access a reference to the underlying `std::error::Error`. Similarly to how `failure::Error` doesn't implement `Fail` directly but provides `as_fail`. Note that since this RFC is so sparse, there's really not much to implement, and most other methods which are used to actually build errors are local to this crate (e.g. `ResultExt::with_context`). I have a branch where I've tried to apply this crate here: https://github.com/udoprog/amethyst/commit/amethyst-error-full I think I might have accidentally botched some of the `From<T>` implementations, but it should still give an idea of how this type is used. #### Composite APIs Composite APIs are APIs which potentially make use of local error information. Today these tend to lead to "stringy" errors where most of the underlying error information is lost and the errors undergoes a conversion. These are candidates to make use of `amethyst_error::Error` directly right now. The traits I've so far identified that has a tendency to lead to this are: * [`amethyst_assets::Source`](/amethyst/amethyst/blob/master/amethyst_assets/src/source/mod.rs) * [`amethyst_assets::PrefabData`](/amethyst/amethyst/blob/master/amethyst_assets/src/prefab/mod.rs) * [`amethyst_assets::SimpleFormat`](/amethyst/amethyst/blob/master/amethyst_assets/src/asset.rs) * Here's an example where SimpleFormat "stringifies" errors instead of propagating them to work around error constraints: https://github.com/amethyst/amethyst/blob/master/amethyst_ui/src/prefab.rs#L736 * [`amethyst_renderer::Pass/Pipeline` stuff](/amethyst/amethyst/blob/master/amethyst_renderer/src/pipe/pass.rs). Unsure because it spans over to UI and I don't know how "end user" this is. #### Open Discussions * Dropping the `Sync` constraint ([comment](#1220 (comment))). * ~~Either drop `no_std` support or improve it ([comment 1](#1220 (comment)), [comment 2](#1220 (comment) backtrace is no longer optional. Co-authored-by: John-John Tedro <udoprog@tedro.se> Co-authored-by: Thomas Schaller <torkleyy@gmail.com> Co-authored-by: udoprog <udoprog@tedro.se>
1220: Introduce amethyst_error r=omni-viral,torkleyy,LucioFranco a=udoprog Following #1214 This introduces the minimal API necessary to convert existing Error types (some which includes causes). It currently mimics the `failure::Error` API, with methods named according to the ["fix Error" RFC](https://github.com/rust-lang/rfcs/blob/master/text/2504-fix-error.md). That means: * We include the `format_err!` macro and the `ResultExt` trait with an implementation of `with_context` from `failure`. * The error type includes backtraces directly (instead of wrapping it in through e.g. `Context<D>`) in comparison to `failure`. * We include a blanket `From<E> where E: std::error::Error` implementation to convert any type that implements `std::error::Error` into `Error`. * Note: this has the side-effect that this `Error` can't implement `std::error::Error`. * We are using `source` from `std::error::Error` instead of `cause`. * We don't implement `std::error::Error` directly, but we do implement some methods which are similar (`source`). We implement `as_error` to access a reference to the underlying `std::error::Error`. Similarly to how `failure::Error` doesn't implement `Fail` directly but provides `as_fail`. Note that since this RFC is so sparse, there's really not much to implement, and most other methods which are used to actually build errors are local to this crate (e.g. `ResultExt::with_context`). I have a branch where I've tried to apply this crate here: https://github.com/udoprog/amethyst/commit/amethyst-error-full I think I might have accidentally botched some of the `From<T>` implementations, but it should still give an idea of how this type is used. #### Composite APIs Composite APIs are APIs which potentially make use of local error information. Today these tend to lead to "stringy" errors where most of the underlying error information is lost and the errors undergoes a conversion. These are candidates to make use of `amethyst_error::Error` directly right now. The traits I've so far identified that has a tendency to lead to this are: * [`amethyst_assets::Source`](/amethyst/amethyst/blob/master/amethyst_assets/src/source/mod.rs) * [`amethyst_assets::PrefabData`](/amethyst/amethyst/blob/master/amethyst_assets/src/prefab/mod.rs) * [`amethyst_assets::SimpleFormat`](/amethyst/amethyst/blob/master/amethyst_assets/src/asset.rs) * Here's an example where SimpleFormat "stringifies" errors instead of propagating them to work around error constraints: https://github.com/amethyst/amethyst/blob/master/amethyst_ui/src/prefab.rs#L736 * [`amethyst_renderer::Pass/Pipeline` stuff](/amethyst/amethyst/blob/master/amethyst_renderer/src/pipe/pass.rs). Unsure because it spans over to UI and I don't know how "end user" this is. #### Open Discussions * Dropping the `Sync` constraint ([comment](#1220 (comment))). * ~~Either drop `no_std` support or improve it ([comment 1](#1220 (comment)), [comment 2](#1220 (comment) backtrace is no longer optional. Co-authored-by: John-John Tedro <udoprog@tedro.se> Co-authored-by: Thomas Schaller <torkleyy@gmail.com> Co-authored-by: udoprog <udoprog@tedro.se>
@udoprog I think this can be closed, right? |
@torkleyy yeah, you're right. |
Our existing error type is sparse and doesn't include any context of where an error happened.
We should include causes with contexts, and backtraces to our error type to improve our diagnostic capabilities both to users and developers.
Causes
The
failure
allows doing this by adding "contexts":Causal chains are useful because errors can be quite generic (i.e.
I don't feel like ringing the bell
). But in this case an important piece of information is: did it fail when dinging or donging?Backtraces
I think most folks should be familiar with back traces, but I'll just provide some brief thoughts on why they should be included.
Backtraces provide additional context, but can be quite low level. Panics by default include a backtrace. This is something we will be losing out on unless we include it in our error types.
Causes without backtraces could be rendered like this, and should be highly useful for many error cases:
Including backtraces provides much more detailed information:
The text was updated successfully, but these errors were encountered: