use serde_json::Value;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum SoapAdapterError {
    #[error("soap endpoint is missing")]
    MissingEndpoint,
    #[error("invalid SOAP header value path {path}")]
    InvalidHeaderValuePath { path: String },
    #[error("required SOAP header {name} is missing")]
    MissingRequiredHeader { name: String },
    #[error("request failed")]
    Transport(#[from] reqwest::Error),
    #[error("invalid xml payload")]
    InvalidXml(#[from] roxmltree::Error),
    #[error("soap envelope body was not found")]
    MissingBody,
    #[error("soap response body was empty")]
    EmptyBody,
    #[error("soap endpoint returned status {status}")]
    UnexpectedStatus { status: u16, body: Value },
    #[error("soap fault: {message}")]
    SoapFault {
        code: Option<String>,
        message: String,
        detail: Option<Value>,
    },
}
