1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//! Error and warning types for structured data extraction.
//!
//! This module provides two levels of diagnostics:
//!
//! - [`ExtractionError`] -- fatal errors that prevent extraction from completing.
//! These are rare; most issues are captured as warnings instead.
//! - [`ExtractionWarning`] -- non-fatal issues that did not prevent extraction
//! but may affect data quality. Each warning carries a machine-readable
//! [`WarningCode`] for programmatic handling.
//!
//! # Design
//!
//! The extraction pipeline is designed to be lenient: individual format
//! failures (e.g. invalid JSON in a `<script>` tag) are captured as warnings
//! so that other formats can still produce results. Only truly unrecoverable
//! errors propagate as [`ExtractionError`].
//!
//! # Examples
//!
//! ```
//! use schemaorg_rs::error::{ExtractionWarning, WarningCode};
//!
//! let warning = ExtractionWarning {
//! message: "empty JSON-LD script tag".into(),
//! source_location: None,
//! code: WarningCode::MalformedJsonLd,
//! };
//!
//! assert_eq!(warning.code, WarningCode::MalformedJsonLd);
//! ```
use fmt;
use ;
use crateSourceLocation;
use Error;
/// Fatal extraction errors that prevent further processing.
///
/// Most extraction issues are captured as [`ExtractionWarning`]s instead.
/// This enum is reserved for errors that make it impossible to produce
/// any meaningful output.
///
/// # Examples
///
/// ```
/// use schemaorg_rs::error::ExtractionError;
///
/// let err = ExtractionError::Internal("unexpected state".into());
/// assert_eq!(err.to_string(), "extraction failed: unexpected state");
/// ```
/// A non-fatal warning produced during extraction.
///
/// Warnings indicate issues that did not prevent extraction but may
/// affect data quality (e.g. malformed markup, unresolvable references).
///
/// # Examples
///
/// ```
/// use schemaorg_rs::error::{ExtractionWarning, WarningCode};
///
/// let warning = ExtractionWarning {
/// message: "JSON-LD object has no @type".into(),
/// source_location: None,
/// code: WarningCode::EmptyType,
/// };
///
/// assert_eq!(warning.code, WarningCode::EmptyType);
/// ```
/// Machine-readable warning codes.
///
/// Each code corresponds to a specific class of extraction issue.
/// Use these for programmatic filtering and reporting.
///
/// # Examples
///
/// ```
/// use schemaorg_rs::error::WarningCode;
///
/// let code = WarningCode::MalformedJsonLd;
/// assert_eq!(code.to_string(), "malformed-json-ld");
/// ```