Skip to main content

pop_fork/error/
executor.rs

1// SPDX-License-Identifier: GPL-3.0
2
3//! Error types for runtime executor operations.
4
5use smoldot::executor::{host, runtime_call};
6use thiserror::Error;
7
8/// Errors that can occur during runtime execution.
9#[derive(Debug, Error)]
10pub enum ExecutorError {
11	/// Error creating the VM prototype from WASM code.
12	#[error("Failed to create VM prototype: {message}")]
13	PrototypeCreation {
14		/// The error message describing the failure.
15		message: String,
16	},
17
18	/// Error starting the runtime call.
19	#[error("Failed to start runtime call `{method}`: {message}")]
20	StartError {
21		/// The runtime method that failed to start.
22		method: String,
23		/// The error message describing the failure.
24		message: String,
25	},
26
27	/// Error during runtime execution.
28	#[error("Runtime execution error in `{method}`: {message}")]
29	RuntimeError {
30		/// The runtime method that failed.
31		method: String,
32		/// The error message describing the failure.
33		message: String,
34	},
35
36	/// Storage operation failed.
37	#[error("Storage operation failed for key {key}: {message}")]
38	StorageError {
39		/// The storage key that caused the error (hex-encoded).
40		key: String,
41		/// The error message describing the failure.
42		message: String,
43	},
44
45	/// Invalid heap pages value in storage.
46	#[error("Invalid heap pages value: {message}")]
47	InvalidHeapPages {
48		/// The error message describing the invalid value.
49		message: String,
50	},
51}
52
53impl From<host::NewErr> for ExecutorError {
54	fn from(err: host::NewErr) -> Self {
55		ExecutorError::PrototypeCreation { message: err.to_string() }
56	}
57}
58
59impl From<runtime_call::Error> for ExecutorError {
60	fn from(err: runtime_call::Error) -> Self {
61		ExecutorError::RuntimeError { method: String::new(), message: err.to_string() }
62	}
63}
64
65impl From<runtime_call::ErrorDetail> for ExecutorError {
66	fn from(err: runtime_call::ErrorDetail) -> Self {
67		ExecutorError::RuntimeError { method: String::new(), message: err.to_string() }
68	}
69}