specta_jsonschema/
error.rs1use std::io;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5 #[error("IO error: {0}")]
6 Io(#[from] io::Error),
7
8 #[error("JSON serialization error: {0}")]
9 Json(#[from] serde_json::Error),
10
11 #[error("Invalid schema version: {0}")]
12 InvalidSchemaVersion(String),
13
14 #[error("Duplicate type name '{name}' at {location1} and {location2}")]
15 DuplicateTypeName {
16 name: String,
17 location1: String,
18 location2: String,
19 },
20
21 #[error("Invalid type name '{name}' at {path}")]
22 InvalidTypeName { name: String, path: String },
23
24 #[error("Unable to convert schema: {0}")]
25 ConversionError(String),
26
27 #[error("Format error: {message}: {source}")]
28 Format {
29 message: &'static str,
30 source: specta::FormatError,
31 },
32
33 #[error("Unsupported DataType: {0}")]
34 UnsupportedDataType(String),
35
36 #[error("Invalid reference: {0}")]
37 InvalidReference(String),
38}
39
40impl Error {
41 pub(crate) fn format(message: &'static str, source: specta::FormatError) -> Self {
42 Self::Format { message, source }
43 }
44}