chainerror/booksrc/tutorial1.md

12 lines
405 B
Markdown
Raw Normal View History

2018-12-20 15:14:21 +01:00
## Simple String Errors
The most simplest of doing error handling in rust is by returning `String` as a `Box<Error>`.
2018-12-20 16:36:04 +01:00
As you can see by running the example (the "Play" button in upper right of the code block), this only
prints out the last `Error`.
2018-12-20 15:14:21 +01:00
If the rust `main` function returns an Err(), this Err() will be displayed with `std::fmt::Debug`.
2018-12-20 14:52:06 +01:00
~~~rust
{{#include ../examples/tutorial1.rs:2:}}
~~~