-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: book section on error handling (#393)
- Loading branch information
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Error handling <img align="right" width="73" height="45" src="https://raw.githubusercontent.com/tskit-dev/administrative/main/logos/svg/tskit-rust/Tskit_rust_logo.eps.svg"> | ||
|
||
The error type is [`tskit::error::TskitError`](https://docs.rs/tskit/latest/tskit/error/enum.TskitError.html#). | ||
|
||
This type implements `Display` and may thus be printed via: | ||
|
||
```rust, noplayground, ignore | ||
let x = match operation() { | ||
Ok(y) => y, | ||
Err(e) => panic("{}", e); | ||
}; | ||
``` | ||
|
||
The enum variant `TskitError::ErrorCode` represents integer return values from `tskit-c`. | ||
When printed via `Display`, the detailed error message is fetched. | ||
When printed via `Debug`, the numerical error code is shown. | ||
|