From 49879d1b0939f845f57c2c5d689b392293d736b4 Mon Sep 17 00:00:00 2001 From: Greg Lamberson Date: Fri, 15 May 2026 16:46:11 -0500 Subject: [PATCH] refactor(error,session)!: remove Error::into_other_kind Removes `Error::into_other_kind` from `ironrdp-error` and its sole in-tree caller's adjacent dead code in `ironrdp-session::legacy`. `Error::into_other_kind` was a generic kind-conversion shortcut with one workspace caller: `ironrdp_session::legacy::map_error`. Its `Kind: Into` bound led to the lossy `From for SessionErrorKind` impl in `legacy.rs` that collapsed every connector kind to `Custom` or `General`, losing detail at the conversion boundary. `map_error` now calls `SessionError::custom("connector error", error)`, which wraps the full `ConnectorError` as a typed source via `Error::with_source`. Consumers walking `core::error::Error::source()` reach the original kind, context, and location. With `into_other_kind` gone, the `From for SessionErrorKind` impl in `legacy.rs` has no callers and is removed too. Both removals are breaking changes (hence the `!`), but neither item was part of an API consumers were expected to use. Signed-off-by: Greg Lamberson Assisted-by: Claude Code (Anthropic, Opus) --- crates/ironrdp-error/src/lib.rs | 15 --------------- crates/ironrdp-session/src/legacy.rs | 17 ++--------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/crates/ironrdp-error/src/lib.rs b/crates/ironrdp-error/src/lib.rs index 09a44f651..7aae0f79f 100644 --- a/crates/ironrdp-error/src/lib.rs +++ b/crates/ironrdp-error/src/lib.rs @@ -106,21 +106,6 @@ impl Error { } } - pub fn into_other_kind(self) -> Error - where - Kind: Into, - { - Error { - kind: self.kind.into(), - #[cfg(feature = "alloc")] - meta: self.meta, - #[cfg(not(feature = "alloc"))] - context: self.context, - #[cfg(not(feature = "alloc"))] - location: self.location, - } - } - pub fn kind(&self) -> &Kind { &self.kind } diff --git a/crates/ironrdp-session/src/legacy.rs b/crates/ironrdp-session/src/legacy.rs index 44e1399f0..1c755ce75 100644 --- a/crates/ironrdp-session/src/legacy.rs +++ b/crates/ironrdp-session/src/legacy.rs @@ -1,18 +1,5 @@ -use crate::SessionError; - -// FIXME: code should be fixed so that we never need this conversion -// For that, some code from this ironrdp_session::legacy and ironrdp_connector::legacy modules should be moved to ironrdp_pdu itself -impl From for crate::SessionErrorKind { - fn from(value: ironrdp_connector::ConnectorErrorKind) -> Self { - match value { - ironrdp_connector::ConnectorErrorKind::Custom | ironrdp_connector::ConnectorErrorKind::Credssp(_) => { - crate::SessionErrorKind::Custom - } - _ => crate::SessionErrorKind::General, - } - } -} +use crate::{SessionError, SessionErrorExt as _}; pub(crate) fn map_error(error: ironrdp_connector::ConnectorError) -> SessionError { - error.into_other_kind() + SessionError::custom("connector error", error) }