Announcing Rust 1.13
OK, here&#x27;s some error handling I wrote about a year ago, for an RSS feed reader.  This code
calls lots of packages with their own error types. If anything fails, an error bubbles up.
Those had to be packed up into a single type for Rust&#x27;s error handling.  What&#x27;s changed that would make this more concise?<p><pre><code>    pub type FeedResult&lt;T&gt; = Result&lt;T, FeedError&gt;;  &#x2F;&#x2F; return type, result or error

    &#x2F;&#x2F; A set of errors that can occur handling RSS or Atom feeds.
    pub enum FeedError {
        FeedIoError(io::Error),                         &#x2F;&#x2F; error at the I&#x2F;O level
        FeedHTTPError(hyper::Error),                    &#x2F;&#x2F; error at the HTTP level
        FeedXMLParseError(xml::BuilderError),           &#x2F;&#x2F; error at the XML level
        FeedDateParseError(chrono::format::ParseError), &#x2F;&#x2F; error at the date parsing level
        FeedUnknownFeedTypeError,                       &#x2F;&#x2F; wrong feed type
        FeedFieldError(String),                         &#x2F;&#x2F; required RSS field missing
        FeedWasHTMLError(String)                        &#x2F;&#x2F; expected XML, got HTML
    }
    &#x2F;&#x2F;
    &#x2F;&#x2F;  Encapsulate errors from each of the lower level error types
    &#x2F;&#x2F;
    impl convert::From&lt;hyper::Error&gt; for FeedError {
        fn from(err: hyper::Error) -&gt; FeedError {
            FeedError::FeedHTTPError(err)
        }
    }
    impl convert::From&lt;io::Error&gt; for FeedError {
        fn from(err: io::Error) -&gt; FeedError {
            FeedError::FeedIoError(err)
        }
    }
    </code></pre>
(More of those are required, one for each enum value...)
(Then we need this.)<p><pre><code>    &#x2F;&#x2F;   Convert FeedError to text string.
    impl fmt::Display for FeedError {
        fn fmt(&amp;self, f: &amp;mut fmt::Formatter) -&gt; fmt::Result {
            match self {
                &amp;FeedError::FeedIoError(ref xerr) =&gt; xerr.fmt(f),   &#x2F;&#x2F; I&#x2F;O error
                &amp;FeedError::FeedHTTPError(ref xerr) =&gt; xerr.fmt(f), &#x2F;&#x2F; HTTP error
                &amp;FeedError::FeedXMLParseError(ref xerr) =&gt; xerr.fmt(f), &#x2F;&#x2F; XML parse error
                &amp;FeedError::FeedDateParseError(ref xerr) =&gt; xerr.fmt(f), &#x2F;&#x2F; Date parse error
                &amp;FeedError::FeedUnknownFeedTypeError =&gt; write!(f, &quot;Unknown feed type.&quot;),
                &amp;FeedError::FeedFieldError(ref s) =&gt; write!(f, &quot;Required field \&quot;{}\&quot; missing from RSS&#x2F;Atom feed.&quot;, s),
                &amp;FeedError::FeedWasHTMLError(ref s) =&gt; write!(f, &quot;Expected an RSS&#x2F;ATOM feed but received a web page \&quot;{}\&quot;.&quot;, s)
                &#x2F;&#x2F;_(ref xerr) =&gt; xerr.fmt(f) &#x2F;&#x2F; would be convenient, but not allowed in Rust.
            }
        }
</code></pre>
This sort of thing is why I like Python&#x27;s exception hierarchy.  If you catch the higher level errors,
you get all the lower level ones, too, without losing the info about what went wrong.