dtolnay / thiserror

derive(Error) for struct and enum error types

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flag to disable auto-detected source

webmaster128 opened this issue · comments

I have an error enum that I want to convert from snafu to thiserror with the following case:

    #[error("Error serializing type {source}: {msg}")]
    SerializeErr {
        /// the source type that was attempted
        source: String,
        msg: String,
        #[cfg(feature = "backtraces")]
        backtrace: Backtrace,
    },

It looks the field source gets some unintended special treatment such that my code does not compile. Renaming the field solves the problem. But can this be sone without changing the field name?

Is it possible to do something like #[snafu(source(false))]? I tried using #[source(false)] but this causes my error to not derive Display anymore. Is the use of #[source(false)] correct? I did not see it in documentation.