use thiserror::Error;
use fastly::http::request::SendError;
#[derive(Error, Debug)]
#[allow(clippy::large_enum_variant)]
pub enum ExecutionError {
#[error("xml parsing error: {0}")]
XMLError(#[from] quick_xml::Error),
#[error("tag `{0}` is missing required parameter `{1}`")]
MissingRequiredParameter(String, String),
#[error("unexpected `{0}` opening tag")]
UnexpectedOpeningTag(String),
#[error("unexpected `{0}` closing tag")]
UnexpectedClosingTag(String),
#[error("invalid request URL provided: `{0}`")]
InvalidRequestUrl(String),
#[error("error sending request: {0}")]
RequestError(#[from] SendError),
#[error("received unexpected status code for fragment `{0}`: {1}")]
UnexpectedStatus(String, u16),
#[error("unexpected end of document")]
UnexpectedEndOfDocument,
#[error("writer error: {0}")]
WriterError(#[from] std::io::Error),
#[error("expression failed to evaluate: `{0}`")]
ExpressionError(String),
#[error("failed to create a regular expression")]
RegexError(#[from] regex::Error),
#[error("failed to execute a function: `{0}`")]
FunctionError(String),
}
pub type Result<T> = std::result::Result<T, ExecutionError>;