//! ref: composer/src/Composer/Downloader/TransportException.php use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct TransportException { pub message: String, pub code: i64, pub(crate) headers: Option>, pub(crate) response: Option, pub(crate) status_code: Option, pub(crate) response_info: Vec, } impl TransportException { pub fn new(message: String, code: i64) -> Self { Self { message, code, headers: None, response: None, status_code: None, response_info: vec![], } } /// PHP exposes ($message, $code = 0) — alias of `new` used at call sites where the /// status/exception code is provided up-front. pub fn new_with_code(message: String, code: i64) -> Self { Self::new(message, code) } pub fn get_code(&self) -> i64 { self.code } pub fn get_message(&self) -> &str { &self.message } pub fn set_headers(&mut self, headers: Vec) { self.headers = Some(headers); } pub fn get_headers(&self) -> Option<&Vec> { self.headers.as_ref() } pub fn set_response(&mut self, response: Option) { self.response = response; } pub fn get_response(&self) -> Option<&str> { self.response.as_deref() } pub fn set_status_code(&mut self, status_code: Option) { self.status_code = status_code; } pub fn get_status_code(&self) -> Option { self.status_code } pub fn get_response_info(&self) -> &Vec { &self.response_info } pub fn set_response_info(&mut self, response_info: Vec) { self.response_info = response_info; } } impl std::fmt::Display for TransportException { fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { todo!() } } impl std::error::Error for TransportException {}