shapes_converter/shex_to_uml/
shex2uml_error.rs1use std::io;
2
3use prefixmap::{IriRef, PrefixMapError};
4use shex_ast::{Schema, SchemaJsonError, ShapeExprLabel};
5use thiserror::Error;
6
7use super::UmlError;
8
9#[derive(Error, Debug)]
10pub enum ShEx2UmlError {
11 #[error("Shape {iri} not found in schema {schema:?}")]
12 ShapeNotFound { iri: IriRef, schema: Schema },
13
14 #[error("Shape reference {sref} not found in schema {schema:?}")]
15 ShapeRefNotFound {
16 sref: ShapeExprLabel,
17 schema: Schema,
18 },
19
20 #[error("No shapes found in schema to convert to SPARQL. Schema\n{schema:?}")]
21 NoShapes { schema: Schema },
22
23 #[error(
24 "No shape found to convert to SPARQL because list of shapes is empty. Schema\n{schema:?}"
25 )]
26 EmptyShapes { schema: Schema },
27
28 #[error(transparent)]
29 SchemaError {
30 #[from]
31 err: SchemaJsonError,
32 },
33
34 #[error(transparent)]
35 UmlError {
36 #[from]
37 err: UmlError,
38 },
39
40 #[error(transparent)]
41 PrefixMapError {
42 #[from]
43 err: PrefixMapError,
44 },
45
46 #[error("Couldn't create temporary file to generate PlantUML content")]
47 TempFileError { err: io::Error },
48
49 #[error("Wrong cardinality: ({min},{max})")]
50 WrongCardinality { min: i32, max: i32 },
51
52 #[error("Not found environment variable: {env_name}, which should point to the folder where the external tool PlantUML is located")]
53 NoPlantUMLPath { env_name: String },
54
55 #[error("Error launching command: {command:?}\nError: {error} ")]
56 PlantUMLCommandError { command: String, error: io::Error },
57
58 #[error("Can't open generated temporary file used from PlantUML. Temporary file name: {generated_name}, error: {error:?}")]
59 CantOpenGeneratedTempFile {
60 generated_name: String,
61 error: io::Error,
62 },
63
64 #[error("Can't create temporary file for UML content. Temporary file name: {tempfile_name}, error: {error:?}")]
65 CreatingTempUMLFile {
66 tempfile_name: String,
67 error: io::Error,
68 },
69
70 #[error("Can't copy temporary output file to writer: {temp_name}, error: {error:?}")]
71 CopyingTempFile { temp_name: String, error: io::Error },
72
73 #[error("ShEx2Uml error: Feature not implemented: {msg}")]
74 NotImplemented { msg: String },
75
76 #[error("Not found label: {name}")]
77 NotFoundLabel { name: String },
78}
79
80impl ShEx2UmlError {
81 pub fn not_implemented(msg: &str) -> ShEx2UmlError {
82 ShEx2UmlError::NotImplemented {
83 msg: msg.to_string(),
84 }
85 }
86}