Skip to content
Update rust error authored by umaumax's avatar umaumax
......@@ -29,3 +29,15 @@ file_result: Err(IO(Os { code: 21, kind: Other, message: "Is a directory" }))
```
`source`属性を付加すると既存のエラーをラップして独自のエラーの中に情報を追加できる
[dtolnay/thiserror: derive\(Error\) for struct and enum error types]( https://github.com/dtolnay/thiserror )
``` rs
#[derive(Error, Debug)]
pub enum MyError {
...
#[error(transparent)]
Other(#[from] anyhow::Error), // source and Display delegate to anyhow::Error
}
```
\ No newline at end of file