<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../anyhow/all.html"title="show sidebar"></a></div><inputclass="search-input"name="search"aria-label="Run search in the documentation"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"><divid="help-button"tabindex="-1"><ahref="../help.html"title="help">?</a></div><divid="settings-menu"tabindex="-1"><ahref="../settings.html"title="settings"><imgwidth="22"height="22"alt="Change settings"src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><sectionid="main-content"class="content"><divclass="main-heading"><h1>Crate <aclass="mod"href="#">anyhow</a><buttonid="copy-path"title="Copy item path to clipboard"><imgsrc="../static.files/clipboard-7571035ce49a181d.svg"width="19"height="18"alt="Copy item path"></button></h1><spanclass="out-of-band"><aclass="src"href="../src/anyhow/lib.rs.html#1-730">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p><ahref="https://github.com/dtolnay/anyhow"><imgsrc="https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github"alt="github"/></a><ahref="https://crates.io/crates/anyhow"><imgsrc="https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust"alt="crates-io"/></a><ahref="https://docs.rs/anyhow"><imgsrc="https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs"alt="docs-rs"/></a></p>
the <ahref="https://doc.rust-lang.org/1.78.0/core/error/trait.Error.html"title="trait core::error::Error"><code>std::error::Error</code></a> trait.</p>
.with_context(|| <spanclass="macro">format!</span>(<spanclass="string">"Failed to read instrs from {}"</span>, path))<spanclass="question-mark">?</span>;
...
}</code></pre></div>
<divclass="example-wrap"><preclass="language-console"><code>Error: Failed to read instrs from ./path/to/instrs.json
Caused by:
No such file or directory (os error 2)
</code></pre></div></li>
<li>
<p>Downcasting is supported and can be by value, by shared reference, or by
mutable reference as needed.</p>
<divclass="example-wrap"><preclass="rust rust-example-rendered"><code><spanclass="comment">// If the error was caused by redaction, then return a
</div></details><h2id="reexports"class="section-header">Re-exports<ahref="#reexports"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"id="reexport.format_err"><code>pub use <aclass="macro"href="macro.anyhow.html"title="macro anyhow::anyhow">anyhow</a> as format_err;</code></div></li></ul><h2id="macros"class="section-header">Macros<ahref="#macros"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="macro"href="macro.anyhow.html"title="macro anyhow::anyhow">anyhow</a></div><divclass="desc docblock-short">Construct an ad-hoc error from a string or existing non-<code>anyhow</code> error
value.</div></li><li><divclass="item-name"><aclass="macro"href="macro.bail.html"title="macro anyhow::bail">bail</a></div><divclass="desc docblock-short">Return early with an error.</div></li><li><divclass="item-name"><aclass="macro"href="macro.ensure.html"title="macro anyhow::ensure">ensure</a></div><divclass="desc docblock-short">Return early with an error if a condition is not satisfied.</div></li></ul><h2id="structs"class="section-header">Structs<ahref="#structs"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="struct"href="struct.Chain.html"title="struct anyhow::Chain">Chain</a></div><divclass="desc docblock-short">Iterator of a chain of source errors.</div></li><li><divclass="item-name"><aclass="struct"href="struct.Error.html"title="struct anyhow::Error">Error</a></div><divclass="desc docblock-short">The <code>Error</code> type, a wrapper around a dynamic error type.</div></li></ul><h2id="traits"class="section-header">Traits<ahref="#traits"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="trait"href="trait.Context.html"title="trait anyhow::Context">Context</a></div><divclass="desc docblock-short">Provides the <code>context</code> method for <code>Result</code>.</div></li></ul><h2id="functions"class="section-header">Functions<ahref="#functions"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="fn"href="fn.Ok.html"title="fn anyhow::Ok">Ok</a></div><divclass="desc docblock-short">Equivalent to Ok::<_, anyhow::Error>(value).</div></li></ul><h2id="types"class="section-header">Type Aliases<ahref="#types"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="type"href="type.Result.html"title="type anyhow::Result">Result</a></div><divclass="desc docblock-short"><code>Result<T, Error></code></div></li></ul></section></div></main></body></html>