This repository was archived by the owner on Aug 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -47,15 +47,15 @@ more complex type like `Error` or your custom Error/ErrorKind.
47
47
48
48
When you have a dependency which returns a different error type, often you will
49
49
be inclined to add it as a variant on your own error type. When you do that,
50
- you should tag the underlying error as the ` #[cause] ` of your error:
50
+ you should tag the underlying error as the ` #[fail( cause) ] ` of your error:
51
51
52
52
``` rust
53
53
#[derive(Fail , Debug )]
54
54
pub enum MyError {
55
55
#[fail(display = " Input was invalid UTF-8 at index {}" , _0)]
56
56
Utf8Error (usize ),
57
57
#[fail(display = " {}" , _0)]
58
- Io (#[cause] io :: Error ),
58
+ Io (#[fail( cause) ] io :: Error ),
59
59
}
60
60
```
61
61
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ Backtrace type.
148
148
In contrast to ` backtrace ` , the cause cannot be determined by type name alone
149
149
because it could be any type which implements ` Fail ` . For this reason, if your
150
150
error has an underlying cause field, you need to annotate that field with
151
- the ` #[cause] ` attribute.
151
+ the ` #[fail( cause) ] ` attribute.
152
152
153
153
This can be used in fields of enums as well as structs.
154
154
@@ -162,7 +162,7 @@ use std::io;
162
162
#[derive(Fail , Debug )]
163
163
#[fail(display = " An error occurred." )]
164
164
struct MyError {
165
- #[cause] io_error : io :: Error ,
165
+ #[fail( cause) ] io_error : io :: Error ,
166
166
}
167
167
168
168
/// MyEnumError::cause will return a reference only if it is Variant2,
@@ -172,6 +172,6 @@ enum MyEnumError {
172
172
#[fail(display = " An error occurred." )]
173
173
Variant1 ,
174
174
#[fail(display = " A different error occurred." )]
175
- Variant2 (#[cause] io :: Error ),
175
+ Variant2 (#[fail( cause) ] io :: Error ),
176
176
}
177
177
```
You can’t perform that action at this time.
0 commit comments