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
use meritrank::MeritRankError;
#[allow(dead_code)]
// Define a new error type for better error handling
#[derive(Debug, thiserror::Error)]
pub enum GraphManipulationError {
/// Error when failing to create an edge in the graph
#[error("Failed to create edge: {0}")]
EdgeCreationFailure(String),
/// Error when failing to create a node in the graph
#[error("Failed to create node: {0}")]
NodeCreationFailure(String),
/// Error when failing to create a table in the database
#[error("Failed to create table: {0}")]
TableCreationFailure(String),
/// Error when failing to initiate a transaction in the database
#[error("Failed to initiate transaction: {0}")]
TransactionInitiationFailure(String),
/// Error when failing to prepare a statement for the database
#[error("Failed to prepare statement: {0}")]
StatementPreparationFailure(String),
/// Error when failing to commit a transaction in the database
#[error("Failed to commit transaction: {0}")]
TransactionCommitFailure(String),
/// Error when a specific node could not be found in the graph
#[error("Node not found: {0}")]
NodeNotFound(String),
/// Error when failing to extract data from the database
#[error("Failed to extract data: {0}")]
DataExtractionFailure(String),
/// Error when failing to extract weight data from the database
#[error("Failed to extract weight: {0}")]
WeightExtractionFailure(String),
/// Error when failing to extract record data from the database
#[error("Failed to extract records: {0}")]
RecordsExtractionFailure(String),
/// Error when failing to fetch record data from the database
#[error("Failed to fetch records: {0}")]
FetchRecordsFailure(String),
/// Error when failing to generate a graph from the data
#[error("Failed to generate graph: {0}")]
GraphGenerationFailure(String),
/// Error when failing to write a graph to the database
#[error("Failed to write graph: {0}")]
GraphWriteFailure(String),
/// Error when failing to read a graph from the database
#[error("Failed to read graph: {0}")]
GraphReadFailure(String),
/// Error when a specific node name could not be found in the graph
#[error("Node name not found: {0}")]
NodeNameNotFound(String),
/// Error when failing to select a node from the graph
#[error("Failed to select node: {0}")]
NodeSelectionFailure(String),
/// Error when SPI operation fails. This is a transparent error, carrying the original SPI error.
//#[error(transparent)]
//SpiFailure(#[from] pgrx::spi::Error),
/// Error when merit rank operation fails. This is a transparent error, carrying the original MeritRankError.
#[error(transparent)]
MeritRankFailure(#[from] MeritRankError),
/// Error when failing to lock a mutex for concurrent operations
#[error("Failed to lock mutex: {0}")]
MutexLockFailure(String),
#[error("Context {0} not found")]
UnknownContextFailure(String),
}