use schemars::JsonSchema as DeriveJsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema)]
pub struct ExitInfo {
pub exit_code: i32,
pub message: Option<String>,
}
#[derive(
Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, thiserror::Error,
)]
#[error("{message}")]
pub struct PluginError {
pub code: String,
pub message: String,
pub doc_url: Option<String>,
}
impl PluginError {
#[must_use]
pub fn new(code: impl Into<String>, message: impl Into<String>) -> Self {
Self {
code: code.into(),
message: message.into(),
doc_url: None,
}
}
#[must_use]
pub fn with_doc(mut self, url: impl Into<String>) -> Self {
self.doc_url = Some(url.into());
self
}
}