From 86cbdfc5f65eeea1c93dc5c561aa681ff215170d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Sun, 5 Jan 2020 23:01:55 +0100 Subject: [PATCH 1/2] Refer to Error::source() instead of deprecated cause() --- src/interoperability.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interoperability.md b/src/interoperability.md index d7c852e..360e44e 100644 --- a/src/interoperability.md +++ b/src/interoperability.md @@ -200,11 +200,11 @@ An error type is any type `E` used in a `Result` returned by any public function of your crate. Error types should always implement the [`std::error::Error`] trait which is the mechanism by which error handling libraries like [`error-chain`] abstract over different types of errors, and -which allows the error to be used as the [`cause()`] of another error. +which allows the error to be used as the [`source()`] of another error. [`std::error::Error`]: https://doc.rust-lang.org/std/error/trait.Error.html [`error-chain`]: https://docs.rs/error-chain -[`cause()`]: https://doc.rust-lang.org/std/error/trait.Error.html#method.cause +[`source()`]: https://doc.rust-lang.org/std/error/trait.Error.html#method.source Additionally, error types should implement the [`Send`] and [`Sync`] traits. An error that is not `Send` cannot be returned by a thread run with From c44f833122dfc51be2cdf0e7c0493b7b4a64c5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Sun, 5 Jan 2020 23:14:09 +0100 Subject: [PATCH 2/2] Say that Error::description is deprecated and should not be implemented --- src/interoperability.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/interoperability.md b/src/interoperability.md index 360e44e..ebc14ee 100644 --- a/src/interoperability.md +++ b/src/interoperability.md @@ -269,9 +269,8 @@ impl Error for DoError { /* ... */ } The error message given by the `Display` representation of an error type should be lowercase without trailing punctuation, and typically concise. -The message given by [`Error::description()`] does not matter. Users should -always use `Display` instead of `description()` to print the error. A low-effort -description like `"JSON error"` is sufficient. +[`Error::description()`] should not be implemented. It has been deprecated and users should +always use `Display` instead of `description()` to print the error. [`Error::description()`]: https://doc.rust-lang.org/std/error/trait.Error.html#tymethod.description