From 0641930f6741ca144f85a3c30fbefd19c43ce09c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 14 May 2026 19:58:31 +0900 Subject: feat(port): port TransportException.php --- .../shirabe/src/downloader/transport_exception.rs | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'crates/shirabe/src/downloader') diff --git a/crates/shirabe/src/downloader/transport_exception.rs b/crates/shirabe/src/downloader/transport_exception.rs index 375b3af..a7c64e1 100644 --- a/crates/shirabe/src/downloader/transport_exception.rs +++ b/crates/shirabe/src/downloader/transport_exception.rs @@ -1 +1,58 @@ //! 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![], + } + } + + 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; + } +} -- cgit v1.3.1