foldit_plugin_sdk/error.rs
1//! Error type for the plugin SDK surface.
2
3/// Error raised by a [`crate::Plugin`] method or a proto-to-native decode.
4#[derive(Debug, thiserror::Error)]
5pub enum PluginError {
6 /// The plugin does not implement the requested method.
7 #[error("plugin does not implement this method")]
8 Unsupported,
9 /// A proto message failed to decode into its native form.
10 #[error("proto decode failed: {0}")]
11 Decode(#[from] prost::DecodeError),
12 /// The plugin reported a structured op-level failure.
13 #[error("plugin op error [{code}] {message}")]
14 Op {
15 /// Machine-readable error code (e.g. `"INVALID_INPUT"`).
16 code: String,
17 /// Human-readable message.
18 message: String,
19 },
20 /// Any other failure, carried as a free-form message.
21 #[error("{0}")]
22 Other(String),
23}
24
25/// Result alias for fallible SDK operations.
26pub type Result<T> = core::result::Result<T, PluginError>;