pdfrum_form/error.rs
1//! This crate's error type.
2//!
3//! Interaction is damage-tolerant in the same way parsing is: an event that
4//! cannot be delivered is not an error, it is an event that consumed nothing.
5//! `Err` is reserved for a caller mistake that leaves nothing sensible to
6//! return.
7
8use pdfrum_common::PageIndex;
9
10/// What went wrong.
11#[derive(Debug, thiserror::Error, PartialEq, Eq)]
12#[non_exhaustive]
13pub enum Error {
14 /// An event named a page the context does not carry.
15 #[error("no such page in this form context: {page}")]
16 NoSuchPage {
17 /// The page index asked for.
18 page: PageIndex,
19 },
20 /// An event named a field the form does not have.
21 #[error("no such field in this form: {field}")]
22 NoSuchField {
23 /// The field index asked for.
24 field: u32,
25 },
26}