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,13 @@
|
|||
|
||||
<div id="content" class="content">
|
||||
<main>
|
||||
<pre><pre class="playpen"><code class="language-rust">use crate::chainerror::*;
|
||||
<a class="header" href="#saving-coding-chars" id="saving-coding-chars"><h2>Saving coding chars</h2></a>
|
||||
<p>Because decorating an error with more information should not
|
||||
let you jump through hoops, <code>chainerror</code> has a quick macro for that.</p>
|
||||
<p><code>mstrerror!()</code> fits right into <code>.map_err()</code> letting you quickly add
|
||||
more debug strings.</p>
|
||||
<p><code>mstrerror!()</code> even understands <code>format!()</code> syntax like <code>println!()</code>.</p>
|
||||
<pre><pre class="playpen"><code class="language-rust">use crate::chainerror::*;
|
||||
use std::error::Error;
|
||||
use std::result::Result;
|
||||
|
||||
|
@ -150,7 +156,8 @@ fn do_some_io() -> Result<(), Box<Error>> {
|
|||
}
|
||||
|
||||
fn func2() -> Result<(), Box<Error>> {
|
||||
do_some_io().map_err(mstrerr!("func2 error"))?;
|
||||
let filename = "foo.txt";
|
||||
do_some_io().map_err(mstrerr!("Error reading '{}'", filename))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue