From bbb2f9454b6580fcbd337ced61b5a1888d52ce8d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Jun 2026 01:50:16 +0900 Subject: refactor(io): model ask_and_validate validators with anyhow::Result PHP's askAndValidate throws when a validator rejects input. Change the IOInterface validator callback and return type to anyhow::Result so the call sites can return Err instead of panic, faithfully modeling the throw semantics already supported by the Question layer. Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/src/io/io_interface.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/shirabe/src/io/io_interface.rs') diff --git a/crates/shirabe/src/io/io_interface.rs b/crates/shirabe/src/io/io_interface.rs index e48f9ce..e33cea2 100644 --- a/crates/shirabe/src/io/io_interface.rs +++ b/crates/shirabe/src/io/io_interface.rs @@ -101,10 +101,10 @@ pub trait IOInterfaceImmutable: std::fmt::Debug { fn ask_and_validate( &self, question: String, - validator: Box PhpMixed>, + validator: Box anyhow::Result>, attempts: Option, default: PhpMixed, - ) -> PhpMixed; + ) -> anyhow::Result; fn ask_and_hide_answer(&self, question: String) -> Option; @@ -279,10 +279,10 @@ impl IOInterfaceImmutable for Rc> { fn ask_and_validate( &self, question: String, - validator: Box PhpMixed>, + validator: Box anyhow::Result>, attempts: Option, default: PhpMixed, - ) -> PhpMixed { + ) -> anyhow::Result { self.borrow() .ask_and_validate(question, validator, attempts, default) } -- cgit v1.3.1