rust-lang-deprecated / error-chain

Error boilerplate for Rust
Apache License 2.0
728 stars 111 forks source link

How to implement complex display expression? #268

Open jmjoy opened 5 years ago

jmjoy commented 5 years ago

For example:

errors {
        #[doc = "Response not complete, first is protocol status and second is app status, see fastcgi protocol."]
        EndRequest(protocol_status: ProtocolStatus, app_status: u32) {
            description("End request error."),
            display(match protocol_status {
                ProtocolStatus::CantMpxConn => "This app can't multiplex [CantMpxConn]; AppStatus: {}",
                ProtocolStatus::Overloaded => "New request rejected; too busy [OVERLOADED]; AppStatus: {}",
                ProtocolStatus::UnknownRole => "Role value not known [UnknownRole]; AppStatus: {}",
                _ => unreachable!(),
            }, app_status),
        }

}

But now, display not support first argument is string literal, so more complex expression of display is not work, is there a choice to support it?