mirror of
https://github.com/haraldh/chainerror.git
synced 2025-06-06 16:14:43 +02:00
deploy: 1d43a39c61
This commit is contained in:
parent
bc07729890
commit
12caec03a0
18 changed files with 28810 additions and 256 deletions
|
@ -160,32 +160,32 @@ prints out the last <code>Error</code>.</p>
|
|||
and improves inspecting the sources of an error.</p>
|
||||
<p>You can also run the tutorial examples in the checked out
|
||||
<a href="https://github.com/haraldh/chainerror">chainerror git repo</a>.</p>
|
||||
<pre><code>$ cargo run -q --example tutorial1
|
||||
<pre><code class="language-console">$ cargo run -q --example tutorial1
|
||||
</code></pre>
|
||||
<pre><pre class="playpen"><code class="language-rust">use std::error::Error;
|
||||
use std::io;
|
||||
use std::result::Result;
|
||||
|
||||
fn do_some_io() -> Result<(), Box<Error + Send + Sync>> {
|
||||
fn do_some_io() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
Err(io::Error::from(io::ErrorKind::NotFound))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn func2() -> Result<(), Box<Error + Send + Sync>> {
|
||||
fn func2() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
if let Err(_) = do_some_io() {
|
||||
Err("func2 error")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn func1() -> Result<(), Box<Error + Send + Sync>> {
|
||||
fn func1() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
if let Err(_) = func2() {
|
||||
Err("func1 error")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<Error + Send + Sync>> {
|
||||
fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
func1()
|
||||
}
|
||||
</code></pre></pre>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue