pdfrum_text/error.rs
1//! This crate's error type.
2
3/// What can go wrong querying an extracted page.
4///
5/// [`extract`](crate::extract) itself is infallible — every damaged input is a
6/// recorded [`Diagnostic`](pdfrum_common::Diagnostic), not an `Err`. This enum
7/// exists for the query side, where a caller can hand in an index that does
8/// not name a character.
9#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
10#[non_exhaustive]
11pub enum Error {
12 /// A character index ran past the end of the extracted character list.
13 #[error("character index {index} is past the end of a {len}-character page")]
14 CharIndexOutOfRange {
15 /// The index that was asked for.
16 index: crate::CharIndex,
17 /// How many characters the page has.
18 len: usize,
19 },
20}