graphitepdf-errors 0.2.0

Shared error types for the GraphitePDF workspace.
Documentation

Overview

graphitepdf-errors defines the common Result<T> alias and GraphitePdfError enum used across the GraphitePDF workspace.


Scope

graphitepdf-errors contains:

  • Result<T> as the standard workspace result alias
  • GraphitePdfError for I/O, layout, rendering, encoding, and validation failures
  • a minimal dependency footprint centered on thiserror

Installation

cargo add graphitepdf-errors

API Summary

Category Items
Result alias Result<T>
Shared error enum GraphitePdfError

Example

use graphitepdf_errors::{GraphitePdfError, Result};

fn validate_page_width(width: f32) -> Result<()> {
    if width <= 0.0 {
        return Err(GraphitePdfError::InvalidPageSize(format!(
            "width must be positive, got {width}"
        )));
    }

    Ok(())
}

fn main() {
    assert!(validate_page_width(595.0).is_ok());
    assert!(validate_page_width(0.0).is_err());
}

Design Principles

  • keep the shared error surface small and predictable
  • support workspace-wide consistency for fallible APIs
  • avoid pulling unrelated policy into the lowest layer
  • remain useful both for internal crates and external consumers

Role In GraphitePDF

This crate lives at the bottom of the workspace and provides a shared error vocabulary for layout, rendering, asset loading, and PDF generation flows.


License

MIT