Skip to main content

pop_fork/error/
builder.rs

1// SPDX-License-Identifier: GPL-3.0
2
3//! Error types for block builder operations.
4
5use super::{BlockError, ExecutorError, LocalStorageError, RemoteStorageError};
6use thiserror::Error;
7
8/// Errors that can occur during block building.
9#[derive(Debug, Error)]
10pub enum BlockBuilderError {
11	/// Error from the runtime executor.
12	#[error("Executor error: {0}")]
13	Executor(#[from] ExecutorError),
14
15	/// Error from the storage layer.
16	#[error("Storage error: {0}")]
17	Storage(#[from] LocalStorageError),
18
19	/// Error from block operations.
20	#[error("Block error: {0}")]
21	Block(#[from] BlockError),
22
23	/// Error decoding data.
24	#[error("Codec error: {0}")]
25	Codec(String),
26
27	/// Block has not been initialized yet.
28	#[error("Block not initialized - call initialize() first")]
29	NotInitialized,
30
31	/// Block has already been initialized.
32	#[error("Block already initialized - initialize() can only be called once")]
33	AlreadyInitialized,
34
35	/// Inherents have not been applied yet.
36	#[error("Inherents not applied - call apply_inherents() before apply_extrinsic()")]
37	InherentsNotApplied,
38
39	/// Inherents have already been applied.
40	#[error("Inherents already applied - apply_inherents() can only be called once")]
41	InherentsAlreadyApplied,
42	/// Block has already been finalized.
43	#[error("Block already finalized")]
44	AlreadyFinalized,
45
46	/// Inherent provider failed.
47	#[error("Inherent provider `{provider}` failed: {message}")]
48	InherentProvider {
49		/// The identifier of the provider that failed.
50		provider: String,
51		/// The error message.
52		message: String,
53	},
54}
55
56impl From<RemoteStorageError> for BlockBuilderError {
57	fn from(err: RemoteStorageError) -> Self {
58		BlockBuilderError::Storage(LocalStorageError::from(err))
59	}
60}