seda_sdk_rs/errors.rs
1//! Error definitions and result type for the `seda_runtime_sdk`.
2//!
3//! This module provides the [`SDKError`] enum representing all possible errors
4//! within the SDK, and a convenient [`Result`] alias for SDK operations.
5
6use thiserror::Error;
7
8/// Represents errors that can occur when using the `seda_runtime_sdk`.
9#[derive(Debug, Error)]
10pub enum SDKError {
11 /// Wraps errors from JSON serialization or deserialization.
12 #[error(transparent)]
13 Serde(#[from] serde_json::Error),
14
15 /// Wraps errors arising from converting bytes into a UTF-8 `String`.
16 #[error(transparent)]
17 FromUtf8Error(#[from] std::string::FromUtf8Error),
18
19 /// Errors encountered when interpreting raw bytes as UTF-8.
20 #[error("{0:?}")]
21 StringBytesConversion(#[from] std::str::Utf8Error),
22
23 /// Wraps errors when converting a byte slice into a fixed-size array.
24 #[error(transparent)]
25 NumBytesConversion(#[from] std::array::TryFromSliceError),
26
27 /// Indicates that a value did not meet expected constraints.
28 #[error("Invalid value")]
29 InvalidValue,
30}
31
32/// A specialized `Result` type for SDK operations that return `SDKError`.
33pub type Result<T, E = SDKError> = core::result::Result<T, E>;