diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-12 01:01:35 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-12 01:01:43 +0900 |
| commit | 1e44f5723e4c0e0903d00a61f254901e612fe5e1 (patch) | |
| tree | 9c2e1eec364bbf6418a4072ee7767b04c3df0297 /crates/shirabe-external-packages/src/symfony/console/exception | |
| parent | ddf0a624145b618c05c2ee47414545b99b685f37 (diff) | |
| download | php-shirabe-1e44f5723e4c0e0903d00a61f254901e612fe5e1.tar.gz php-shirabe-1e44f5723e4c0e0903d00a61f254901e612fe5e1.tar.zst php-shirabe-1e44f5723e4c0e0903d00a61f254901e612fe5e1.zip | |
feat(symfony-console): port Symfony Console and make the workspace compile
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/console/exception')
8 files changed, 113 insertions, 8 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/exception/command_not_found_exception.rs b/crates/shirabe-external-packages/src/symfony/console/exception/command_not_found_exception.rs index f1ed60b..ea259b3 100644 --- a/crates/shirabe-external-packages/src/symfony/console/exception/command_not_found_exception.rs +++ b/crates/shirabe-external-packages/src/symfony/console/exception/command_not_found_exception.rs @@ -1,13 +1,34 @@ +use super::exception_interface::ExceptionInterface; +use super::invalid_argument_exception::InvalidArgumentException; + #[derive(Debug)] pub struct CommandNotFoundException { - pub message: String, - pub code: i64, + inner: InvalidArgumentException, + alternatives: Vec<String>, +} + +impl CommandNotFoundException { + pub fn new(message: String, alternatives: Vec<String>, code: i64) -> Self { + Self { + inner: InvalidArgumentException(shirabe_php_shim::InvalidArgumentException { + message, + code, + }), + alternatives, + } + } + + pub fn get_alternatives(&self) -> &Vec<String> { + &self.alternatives + } } impl std::fmt::Display for CommandNotFoundException { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.message) + write!(f, "{}", self.inner) } } impl std::error::Error for CommandNotFoundException {} + +impl ExceptionInterface for CommandNotFoundException {} diff --git a/crates/shirabe-external-packages/src/symfony/console/exception/invalid_argument_exception.rs b/crates/shirabe-external-packages/src/symfony/console/exception/invalid_argument_exception.rs index 658ed8c..f4c8299 100644 --- a/crates/shirabe-external-packages/src/symfony/console/exception/invalid_argument_exception.rs +++ b/crates/shirabe-external-packages/src/symfony/console/exception/invalid_argument_exception.rs @@ -1,13 +1,14 @@ +use super::exception_interface::ExceptionInterface; + #[derive(Debug)] -pub struct InvalidArgumentException { - pub message: String, - pub code: i64, -} +pub struct InvalidArgumentException(pub shirabe_php_shim::InvalidArgumentException); impl std::fmt::Display for InvalidArgumentException { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.message) + write!(f, "{}", self.0) } } impl std::error::Error for InvalidArgumentException {} + +impl ExceptionInterface for InvalidArgumentException {} diff --git a/crates/shirabe-external-packages/src/symfony/console/exception/invalid_option_exception.rs b/crates/shirabe-external-packages/src/symfony/console/exception/invalid_option_exception.rs new file mode 100644 index 0000000..b4c0cd8 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/exception/invalid_option_exception.rs @@ -0,0 +1,15 @@ +use super::exception_interface::ExceptionInterface; +use super::invalid_argument_exception::InvalidArgumentException; + +#[derive(Debug)] +pub struct InvalidOptionException(pub InvalidArgumentException); + +impl std::fmt::Display for InvalidOptionException { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +impl std::error::Error for InvalidOptionException {} + +impl ExceptionInterface for InvalidOptionException {} diff --git a/crates/shirabe-external-packages/src/symfony/console/exception/logic_exception.rs b/crates/shirabe-external-packages/src/symfony/console/exception/logic_exception.rs new file mode 100644 index 0000000..20870dc --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/exception/logic_exception.rs @@ -0,0 +1,14 @@ +use super::exception_interface::ExceptionInterface; + +#[derive(Debug)] +pub struct LogicException(pub shirabe_php_shim::LogicException); + +impl std::fmt::Display for LogicException { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +impl std::error::Error for LogicException {} + +impl ExceptionInterface for LogicException {} diff --git a/crates/shirabe-external-packages/src/symfony/console/exception/missing_input_exception.rs b/crates/shirabe-external-packages/src/symfony/console/exception/missing_input_exception.rs new file mode 100644 index 0000000..60a984e --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/exception/missing_input_exception.rs @@ -0,0 +1,15 @@ +use super::exception_interface::ExceptionInterface; +use super::runtime_exception::RuntimeException; + +#[derive(Debug)] +pub struct MissingInputException(pub RuntimeException); + +impl std::fmt::Display for MissingInputException { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +impl std::error::Error for MissingInputException {} + +impl ExceptionInterface for MissingInputException {} diff --git a/crates/shirabe-external-packages/src/symfony/console/exception/mod.rs b/crates/shirabe-external-packages/src/symfony/console/exception/mod.rs index 25750a1..356b595 100644 --- a/crates/shirabe-external-packages/src/symfony/console/exception/mod.rs +++ b/crates/shirabe-external-packages/src/symfony/console/exception/mod.rs @@ -1,7 +1,17 @@ pub mod command_not_found_exception; pub mod exception_interface; pub mod invalid_argument_exception; +pub mod invalid_option_exception; +pub mod logic_exception; +pub mod missing_input_exception; +pub mod namespace_not_found_exception; +pub mod runtime_exception; pub use command_not_found_exception::*; pub use exception_interface::*; pub use invalid_argument_exception::*; +pub use invalid_option_exception::*; +pub use logic_exception::*; +pub use missing_input_exception::*; +pub use namespace_not_found_exception::*; +pub use runtime_exception::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/exception/namespace_not_found_exception.rs b/crates/shirabe-external-packages/src/symfony/console/exception/namespace_not_found_exception.rs new file mode 100644 index 0000000..53801bf --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/exception/namespace_not_found_exception.rs @@ -0,0 +1,15 @@ +use super::command_not_found_exception::CommandNotFoundException; +use super::exception_interface::ExceptionInterface; + +#[derive(Debug)] +pub struct NamespaceNotFoundException(pub CommandNotFoundException); + +impl std::fmt::Display for NamespaceNotFoundException { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +impl std::error::Error for NamespaceNotFoundException {} + +impl ExceptionInterface for NamespaceNotFoundException {} diff --git a/crates/shirabe-external-packages/src/symfony/console/exception/runtime_exception.rs b/crates/shirabe-external-packages/src/symfony/console/exception/runtime_exception.rs new file mode 100644 index 0000000..9efabed --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/exception/runtime_exception.rs @@ -0,0 +1,14 @@ +use super::exception_interface::ExceptionInterface; + +#[derive(Debug)] +pub struct RuntimeException(pub shirabe_php_shim::RuntimeException); + +impl std::fmt::Display for RuntimeException { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +impl std::error::Error for RuntimeException {} + +impl ExceptionInterface for RuntimeException {} |
