You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+15-1Lines changed: 15 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,20 @@
1
1
# fs-err Changelog
2
2
3
-
* Change errors to output original `std::io::Error` information Display by default. This functionality can be disabled for [anyhow](https://docs.rs/anyhow/latest/anyhow/) users by using the new feature `expose_original_error` ([#60](https://github.com/andrewhickman/fs-err/pull/60)).
3
+
## 3.0.0
4
+
5
+
* Error messages now include the original message from `std::io::Error` by default ([#60](https://github.com/andrewhickman/fs-err/pull/60)). Previously this was exposed through the [`Error::source()`](https://doc.rust-lang.org/stable/std/error/trait.Error.html#method.source) method. For example, previously a message would look like:
6
+
7
+
```
8
+
failed to open file `file.txt`
9
+
```
10
+
11
+
and you would have to remember to print the source, or use a library like `anyhow` to print the full chain of source errors. The new error message includes the cause by default
12
+
13
+
```
14
+
failed to open file `file.txt`: The system cannot find the file specified. (os error 2)
15
+
```
16
+
17
+
Note that the original error is no longer exposed though [`Error::source()`](https://doc.rust-lang.org/stable/std/error/trait.Error.html#method.source) by default. If you need access to it, you can restore the previous behaviour with the `expose_original_error` feature flag.
*`expose_original_error`: when enabled, the [`Error::source()`](https://doc.rust-lang.org/stable/std/error/trait.Error.html#method.source) method of errors returned by this crate return the original `io::Error`. To avoid duplication in error messages,
71
+
this also suppresses printing its message in their `Display` implementation, so make sure that you are printing the full error chain.
72
+
73
73
74
74
## Minimum Supported Rust Version
75
75
@@ -79,6 +79,11 @@ This crate will generally be conservative with rust version updates. It uses the
79
79
80
80
If the `tokio` feature is enabled, this crate will inherit the MSRV of the selected [`tokio`](https://crates.io/crates/tokio) version.
Copy file name to clipboardExpand all lines: src/lib.rs
+15-5Lines changed: 15 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -22,13 +22,9 @@ The system cannot find the file specified. (os error 2)
22
22
...but if we use fs-err instead, our error contains more actionable information:
23
23
24
24
```txt
25
-
failed to open file `does not exist.txt`
26
-
caused by: The system cannot find the file specified. (os error 2)
25
+
failed to open file `does not exist.txt`: The system cannot find the file specified. (os error 2)
27
26
```
28
27
29
-
> Note: Users of `anyhow` or other libraries that format an Error's sources can enable the `expose_original_error` feature to control the formatting of the orginal error message.
30
-
> When enabled, the `std::fmt::Display` implementation will emit the failed operation and paths but not the original `std::io::Error`. It will instead provide access via [Error::source](https://doc.rust-lang.org/std/error/trait.Error.html#method.source), which will be used by `anyhow` (or similar) libraries.
31
-
32
28
# Usage
33
29
34
30
fs-err's API is the same as [`std::fs`][std::fs], so migrating code to use it is easy.
* `expose_original_error`: when enabled, the [`Error::source()`](https://doc.rust-lang.org/stable/std/error/trait.Error.html#method.source) method of errors returned by this crate return the original `io::Error`. To avoid duplication in error messages,
65
+
this also suppresses printing its message in their `Display` implementation, so make sure that you are printing the full error chain.
66
+
67
+
68
+
# Minimum Supported Rust Version
69
+
70
+
The oldest rust version this crate is tested on is **1.40**.
71
+
72
+
This crate will generally be conservative with rust version updates. It uses the [`autocfg`](https://crates.io/crates/autocfg) crate to allow wrapping new APIs without incrementing the MSRV.
73
+
74
+
If the `tokio` feature is enabled, this crate will inherit the MSRV of the selected [`tokio`](https://crates.io/crates/tokio) version.
0 commit comments