panproto_parse/error.rs
1//! Error types for full-AST parsing and emission.
2
3use miette::Diagnostic;
4
5/// Errors from full-AST parse and emit operations.
6#[non_exhaustive]
7#[derive(Debug, thiserror::Error, Diagnostic)]
8pub enum ParseError {
9 /// Tree-sitter failed to parse the source file.
10 #[error("tree-sitter parse failed for {path}")]
11 TreeSitterParse {
12 /// The file path that failed to parse.
13 path: String,
14 },
15
16 /// The source file's language could not be detected.
17 #[error("unknown language for file extension: {extension}")]
18 UnknownLanguage {
19 /// The unrecognized file extension.
20 extension: String,
21 },
22
23 /// Schema construction failed during AST walking.
24 #[error("schema construction failed: {reason}")]
25 SchemaConstruction {
26 /// Description of the construction failure.
27 reason: String,
28 },
29
30 /// Emission failed when converting a schema back to source text.
31 #[error("emit failed for protocol {protocol}: {reason}")]
32 EmitFailed {
33 /// The protocol being emitted.
34 protocol: String,
35 /// Description of the emit failure.
36 reason: String,
37 },
38
39 /// Theory extraction from grammar metadata failed.
40 #[error("theory extraction failed: {reason}")]
41 TheoryExtraction {
42 /// Description of the extraction failure.
43 reason: String,
44 },
45
46 /// JSON deserialization of node-types.json failed.
47 #[error("failed to parse node-types.json: {source}")]
48 NodeTypesJson {
49 /// The underlying JSON parse error.
50 #[source]
51 source: serde_json::Error,
52 },
53
54 /// A protocol error propagated from panproto-protocols.
55 #[error(transparent)]
56 Protocol(#[from] panproto_protocols::ProtocolError),
57}