Add transparent error support to derive macro#34
Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
masterror/masterror-derive/src/lib.rs
Lines 568 to 585 in ae6476a
[P1] Transparent struct omits wrapped error from source chain
When deriving a transparent struct, source() calls ::std::error::Error::source on the inner value instead of returning the inner error itself. For a wrapper like #[error(transparent)] struct Wrapper(#[from] std::io::Error);, this implementation yields None because io::Error often has no deeper source, so the original io::Error is no longer reachable through the error chain and cannot be downcast after boxing. Transparent wrappers should expose the wrapped error as the direct source (Some(&self.0)) to preserve the chain.
masterror/masterror-derive/src/lib.rs
Lines 797 to 832 in ae6476a
[P1] Transparent enum variants skip the wrapped error in source()
The source() arm generated for transparent enum variants delegates to the inner error’s own source() rather than returning the inner error itself. As with structs, this causes the wrapped error to disappear from the chain: TransparentEnum::TransparentVariant(std::io::Error::new(...)) reports no source, so callers cannot recover or downcast the actual inner error once it is boxed. The arm should return Some(inner) to keep the wrapper transparent without losing the immediate cause.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
Summary
#[error(transparent)]in the derive macro with validation of wrapper shapeDisplay/sourceandFromgeneration for transparent errors and update docsTesting
https://chatgpt.com/codex/tasks/task_e_68ca3690e7d0832b8c92ead521e47d24