From e583112899cbea7494ffdd73d7de380dd5f808c4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 10 Jun 2026 00:54:22 +0900 Subject: feat(phase-c): resolve exception-handling phase-b TODOs * Catch specific exception types instead of broad/placeholder handling. * Drop the shim Countable trait. --- crates/shirabe/src/command/create_project_command.rs | 3 +-- crates/shirabe/src/command/self_update_command.rs | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'crates/shirabe/src/command') diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index f8fc511..c49d2fc 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -472,8 +472,7 @@ impl CreateProjectCommand { } } Err(e) => { - // TODO(phase-b): catch only PluginBlockedException - if let Some(_pbe) = e.downcast_ref::() { + if e.downcast_ref::().is_some() { io.write_error("Hint: To allow running the config command recommended below before dependencies are installed, run create-project with --no-install."); io.write_error(&format!( "You can then cd into {}, configure allow-plugins, and finally run a composer install to complete the process.", diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs index edc2db8..5948d34 100644 --- a/crates/shirabe/src/command/self_update_command.rs +++ b/crates/shirabe/src/command/self_update_command.rs @@ -26,6 +26,7 @@ use crate::config::Config; use crate::console::input::InputArgument; use crate::console::input::InputOption; use crate::downloader::FilesystemException; +use crate::downloader::TransportException; use crate::factory::Factory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; @@ -435,15 +436,17 @@ impl SelfUpdateCommand { ) { Ok(r) => r.get_body().map(|s| s.to_string()), Err(e) => { - // TODO(phase-b): TransportException::get_status_code mapping from anyhow::Error - if false && e.to_string().contains("404") { + if e.downcast_ref::() + .and_then(|te| te.get_status_code()) + == Some(404) + { return Err(InvalidArgumentException { message: format!("Version \"{}\" could not be found.", update_version), code: 0, } .into()); } - return Err(e.into()); + return Err(e); } }; io.write_error3(" ", false, io_interface::NORMAL); -- cgit v1.3.1