Expand description
§Error Handling
Structured error handling with diagnostics and source location tracking.
§Overview
The error module provides error types and diagnostic types for actionable
error reporting with source location tracking.
§Key Types
RenderError: Main error enum for rendering operationsDiagnostic: Structured diagnostic informationLocation: Source file location (file, line, column)Severity: Error severity levels (Error, Warning, Note)RenderResult: Result type with artifacts and warnings
§Error Hierarchy
§RenderError Variants
RenderError::EngineCreation: Failed to create rendering engineRenderError::InvalidFrontmatter: Malformed YAML frontmatterRenderError::CompilationFailed: Backend compilation errorsRenderError::FormatNotSupported: Requested format not supportedRenderError::UnsupportedBackend: Backend not registeredRenderError::ValidationFailed: Field coercion/validation failureRenderError::QuillConfig: Quill configuration error
§Examples
§Creating Diagnostics
use quillmark_core::{Diagnostic, Location, Severity};
let diag = Diagnostic::new(Severity::Error, "Undefined variable".to_string())
.with_code("E001".to_string())
.with_location(Location {
file: "template.typ".to_string(),
line: 10,
column: 5,
})
.with_hint("Check variable spelling".to_string());
println!("{}", diag.fmt_pretty());Example output:
[ERROR] Undefined variable (E001) at template.typ:10:5
hint: Check variable spelling§Result with Warnings
let result = RenderResult::new(artifacts, OutputFormat::Pdf)
.with_warning(Diagnostic::new(
Severity::Warning,
"Deprecated field used".to_string(),
));§Pretty Printing
The Diagnostic type provides Diagnostic::fmt_pretty() for human-readable output with error code, location, and hints.
§Machine-Readable Output
All diagnostic types implement serde::Serialize for JSON export:
let json = serde_json::to_string(&diagnostic).unwrap();Re-exports§
pub use crate::document::limits::MAX_YAML_DEPTH;
Structs§
- Diagnostic
- Structured diagnostic information.
- Location
- Location information for diagnostics
- Render
Result - Result type containing artifacts and warnings
Enums§
- Parse
Error - Error type for parsing operations
- Render
Error - Main error type for rendering operations.
- Severity
- Error severity levels
Constants§
- MAX_
CARD_ COUNT - Maximum number of CARD blocks allowed per document Prevents memory exhaustion from documents with excessive card blocks
- MAX_
FIELD_ COUNT - Maximum number of fields allowed per document Prevents memory exhaustion from documents with excessive fields
- MAX_
INPUT_ SIZE - Maximum input size for markdown (10 MB)
- MAX_
NESTING_ DEPTH - Maximum nesting depth for markdown structures (100 levels)
- MAX_
YAML_ SIZE - Maximum YAML size (1 MB)
Functions§
- print_
errors - Helper to print structured errors