mirror of
https://github.com/haraldh/chainerror.git
synced 2025-06-06 16:14:43 +02:00
doc update
generated from commit 837c7980e8a5b84be28825303faac0ba28e53446
This commit is contained in:
parent
991a7a0786
commit
188d93a86a
15 changed files with 116 additions and 18 deletions
|
@ -140,7 +140,9 @@
|
|||
|
||||
<div id="content" class="content">
|
||||
<main>
|
||||
<pre><pre class="playpen"><code class="language-rust">use crate::chainerror::*;
|
||||
<a class="header" href="#mapping-errors" id="mapping-errors"><h2>Mapping Errors</h2></a>
|
||||
<p>Now let's get more rust idiomatic by using <code>.map_err()</code>.</p>
|
||||
<pre><pre class="playpen"><code class="language-rust">use crate::chainerror::*;
|
||||
use std::error::Error;
|
||||
use std::result::Result;
|
||||
|
||||
|
@ -445,6 +447,16 @@ fn main() -> Result<(), Box<Error>> {
|
|||
# }
|
||||
# }
|
||||
</code></pre></pre>
|
||||
<p>If you compare the output to the previous example, you will see,
|
||||
that:</p>
|
||||
<pre><code>Error: src/main.rs:19: "func1 error"
|
||||
</code></pre>
|
||||
<p>changed to just:</p>
|
||||
<pre><code>src/main.rs:16: "func1 error"
|
||||
</code></pre>
|
||||
<p>This is, because we caught the error of <code>func1()</code> in <code>main()</code> and print it out ourselves.</p>
|
||||
<p>We can now control, whether to output in <code>Debug</code> or <code>Display</code> mode.
|
||||
Maybe depending on <code>--debug</code> as a CLI argument.</p>
|
||||
|
||||
</main>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue