diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 4f2c7540..5816e741 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -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) diff --git a/book/src/error_handling.md b/book/src/error_handling.md new file mode 100644 index 00000000..4cf78bc1 --- /dev/null +++ b/book/src/error_handling.md @@ -0,0 +1,17 @@ +# Error handling + +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. +