fuel_core_database/
lib.rs1#![deny(clippy::arithmetic_side_effects)]
8#![deny(clippy::cast_possible_truncation)]
9#![deny(missing_docs)]
10#![deny(unused_crate_dependencies)]
11#![deny(warnings)]
12#![deny(unused_variables)]
13
14use fuel_core_storage::{
15 transactional::ReferenceBytesKey,
16 Error as StorageError,
17};
18use fuel_core_types::services::executor::Error as ExecutorError;
19
20#[derive(Debug, derive_more::Display, derive_more::From)]
22#[non_exhaustive]
23#[allow(missing_docs)]
24pub enum Error {
25 #[display(fmt = "error performing serialization or deserialization")]
27 Codec,
28 #[display(
30 fmt = "Invalid database version, expected {expected:#x}, found {found:#x}"
31 )]
32 InvalidDatabaseVersion {
33 found: u32,
35 expected: u32,
37 },
38 #[display(fmt = "Multiple heights found in the commit {heights:?}")]
40 MultipleHeightsInCommit {
41 heights: Vec<u64>,
43 },
44 #[display(fmt = "Failed to advance the height")]
46 FailedToAdvanceHeight,
47 #[display(
49 fmt = "New and old heights are not linked: prev_height: {prev_height:#x}, new_height: {new_height:#x}"
50 )]
51 HeightsAreNotLinked {
52 prev_height: u64,
54 new_height: u64,
56 },
57 #[display(
59 fmt = "The new height is not found, but the old height is set: prev_height: {prev_height:#x}"
60 )]
61 NewHeightIsNotSet {
62 prev_height: u64,
64 },
65 #[display(
66 fmt = "The historical database doesn't have history for the requested height {requested_height:#x}"
67 )]
68 NoHistoryForRequestedHeight { requested_height: u64 },
69 #[display(fmt = "Reached the end of the history")]
70 ReachedEndOfHistory,
71
72 #[cfg(feature = "backup")]
73 #[display(fmt = "BackupEngine initialization error: {}", _0)]
74 BackupEngineInitError(anyhow::Error),
75
76 #[cfg(feature = "backup")]
77 #[display(fmt = "Backup error: {}", _0)]
78 BackupError(anyhow::Error),
79
80 #[cfg(feature = "backup")]
81 #[display(fmt = "Restore error: {}", _0)]
82 RestoreError(anyhow::Error),
83
84 #[display(fmt = "During committing of the changes found conflicting \
85 modifications at column {column} for the key {key:?}")]
86 ConflictingChanges { column: u32, key: ReferenceBytesKey },
87
88 #[from]
90 Other(anyhow::Error),
91}
92
93#[cfg(feature = "test-helpers")]
94impl PartialEq for Error {
95 fn eq(&self, other: &Self) -> bool {
96 self.to_string().eq(&other.to_string())
97 }
98}
99
100impl From<Error> for anyhow::Error {
101 fn from(error: Error) -> Self {
102 anyhow::Error::msg(error)
103 }
104}
105
106impl From<Error> for StorageError {
107 fn from(e: Error) -> Self {
108 StorageError::DatabaseError(Box::new(e))
109 }
110}
111
112impl From<Error> for ExecutorError {
113 fn from(e: Error) -> Self {
114 ExecutorError::StorageError(format!("{}", StorageError::from(e)))
115 }
116}
117
118#[cfg(test)]
119fuel_core_trace::enable_tracing!();