File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,28 @@ add_executable(foo foo.cpp)
46
46
target_link_libraries(foo PRIVATE errors::errors)
47
47
```
48
48
49
+ ## Usage
50
+
51
+ This package contains an ` errors::Error ` class, representing an error object.
52
+ A function that may result in errors should returns this object so that the error could be handled properly.
53
+
54
+ ``` c++
55
+ errors::Error print_hex (const char* number_str);
56
+
57
+ int main() {
58
+ const auto err = print_hex(number_str);
59
+ if (err) {
60
+ // error, do something.
61
+ }
62
+
63
+ // no error, continue.
64
+ }
65
+ ```
66
+
67
+ On a function that returns `errors::Error`, it can returns `errors::nil` to indicate that there's no error or returns an error object
68
+
69
+ See the [examples](./examples) for further details on how to use this package.
70
+
49
71
## License
50
72
51
73
This project is licensed under the terms of the [MIT License](./LICENSE).
You can’t perform that action at this time.
0 commit comments