//! ref: composer/src/Composer/Package/Loader/InvalidPackageException.php use indexmap::IndexMap; use shirabe_php_shim::{Exception, PhpMixed}; #[derive(Debug)] pub struct InvalidPackageException { inner: Exception, errors: Vec, warnings: Vec, data: IndexMap, } impl InvalidPackageException { pub fn new( errors: Vec, warnings: Vec, data: IndexMap, ) -> Self { let message = format!( "Invalid package information: \n{}", errors .iter() .chain(warnings.iter()) .cloned() .collect::>() .join("\n") ); Self { inner: Exception { message, code: 0 }, errors, warnings, data, } } pub fn get_data(&self) -> &IndexMap { &self.data } pub fn get_errors(&self) -> &[String] { &self.errors } pub fn get_warnings(&self) -> &[String] { &self.warnings } } impl std::fmt::Display for InvalidPackageException { fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { todo!() } } impl std::error::Error for InvalidPackageException {}