Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
- [Defining metadata types in rust](./metadata_derive.md)
- [Metadata and tables](./metadata_tables.md)
- [Metadata schema](./metadata_schema.md)

* [Error handling](./error_handling.md)


[Crate prelude](./prelude.md)
Expand Down
17 changes: 17 additions & 0 deletions book/src/error_handling.md
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.