1pub type Result<T, E = Error> = std::result::Result<T, E>;
2
3#[derive(thiserror::Error, Debug)]
4pub enum Error {
5 #[error("Build error: {0}")]
6 Build(String),
7
8 #[error("bindings config is required when python, node, or node_ts output is enabled")]
9 MissingBindingsConfig,
10
11 #[error("connect_client_path is required when the Connect client protocol is enabled")]
12 MissingConnectClientPath,
13
14 #[error(
15 "language bindings (python/node/node_ts/wasm) build on the REST client; they require the REST client protocol to be enabled"
16 )]
17 BindingsRequireRest,
18
19 #[error("Missing annotation for {object}: {message}")]
20 MissingAnnotation { object: String, message: String },
21
22 #[error("Invalid annotation for {object}: {message}")]
23 InvalidAnnotation { object: String, message: String },
24
25 #[error("Invalid models_path template `{template}`: {source}")]
26 InvalidModelsPathTemplate {
27 template: String,
28 #[source]
29 source: syn::Error,
30 },
31
32 #[error("Invalid Rust path `{path}` derived from proto message `{message}`: {source}")]
33 InvalidRustPath {
34 path: String,
35 message: String,
36 #[source]
37 source: syn::Error,
38 },
39
40 #[error("Invalid error_type_path `{path}`: {source}")]
41 InvalidErrorTypePath {
42 path: String,
43 #[source]
44 source: syn::Error,
45 },
46
47 #[error("Invalid {field} `{path}`: {source}")]
48 InvalidConfigPath {
49 field: &'static str,
50 path: String,
51 #[source]
52 source: syn::Error,
53 },
54
55 #[error(
56 "Failed to parse generated tokens as a Rust file: {source}\n--- generated tokens ---\n{tokens}"
57 )]
58 GeneratedParse {
59 tokens: String,
60 #[source]
61 source: syn::Error,
62 },
63
64 #[error("IO error: {0}")]
65 Io(#[from] std::io::Error),
66}