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
//! Unified error types for the ORM crate.
use thiserror::Error;
/// Unified error type for the ORM crate.
#[derive(Debug, Error)]
pub enum OrmError {
/// The detected TypeDB driver or server version lies outside the supported
/// window, or the driver and server speak different protocol bands.
///
/// The inner [`type_bridge_core_lib::version::VersionError`] message is
/// preserved verbatim — including version numbers and remediation text —
/// so no information is lost at the ORM boundary.
#[error("Unsupported version: {0}")]
UnsupportedVersion(#[from] type_bridge_core_lib::version::VersionError),
/// Connection to TypeDB failed.
#[error("Connection error: {0}")]
Connection(String),
/// Query execution failed.
#[error("Query execution error: {0}")]
QueryExecution(String),
/// Transaction already committed or rolled back.
#[error("Transaction error: {0}")]
Transaction(String),
/// Failed to hydrate query results into Rust structs.
#[error("Hydration error for type '{type_name}': {message}")]
Hydration {
/// The entity type name that failed hydration.
type_name: String,
/// A description of what went wrong.
message: String,
},
/// Entity not found.
#[error("Entity not found: {0}")]
NotFound(String),
/// Invalid filter specification.
#[error("Invalid filter: {0}")]
InvalidFilter(String),
/// Runtime descriptor validation failed.
#[error("Descriptor validation error for type '{type_name}': {message}")]
DescriptorValidation {
/// The descriptor type name, or `<registry>` for registry state errors.
type_name: String,
/// A description of what went wrong.
message: String,
},
/// Runtime descriptor conflicts with an existing registration or expected kind.
#[error("Descriptor conflict for type '{type_name}': {message}")]
DescriptorConflict {
/// The descriptor type name.
type_name: String,
/// A description of the conflict.
message: String,
},
/// Runtime descriptor was not registered.
#[error("Descriptor not found for type '{0}'")]
DescriptorNotFound(String),
/// AST compilation failed.
#[error("Compilation error: {0}")]
Compilation(String),
/// Schema management error.
#[error("Schema error: {0}")]
Schema(#[from] crate::schema::SchemaError),
/// Serde JSON error.
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
/// A lifecycle hook rejected or failed the operation.
#[error("Hook error: {0}")]
Hook(#[from] crate::hooks::HookError),
}
/// Convenience Result alias for ORM operations.
pub type Result<T> = std::result::Result<T, OrmError>;