diff options
Diffstat (limited to 'crates/shirabe/src/console/application.rs')
| -rw-r--r-- | crates/shirabe/src/console/application.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 19317363..c6674c77 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -2596,13 +2596,15 @@ impl ApplicationHandle { // override TransportException's code for the purpose of parent::run() using it as process exit code // as http error codes are all beyond the 255 range of permitted exit codes - if e.downcast_ref::<TransportException>().is_some() { - // PHP: ReflectionProperty $reflProp = new \ReflectionProperty($e, 'code'); - // $reflProp->setValue($e, Installer::ERROR_TRANSPORT_EXCEPTION); - // TODO(phase-c): reflection-based mutation of the existing exception is not portable; - // we surface the rewritten code via a fresh TransportException at the call site. - let _ = Installer::ERROR_TRANSPORT_EXCEPTION; - } + // TODO(phase-c): PHP's `instanceof TransportException` also matches the subclass + // MaxFileSizeExceededException, which is a newtype here and is not matched by this downcast. + let e = match e.downcast::<TransportException>() { + Ok(mut e) => { + e.code = Installer::ERROR_TRANSPORT_EXCEPTION; + anyhow::Error::new(e) + } + Err(e) => e, + }; Err(e) } |
