Skip to content

Commit c789d63

Browse files
committed
Document error handling
Closes: #1860 Signed-off-by: Erik Sjölund <[email protected]>
1 parent e0a6f43 commit c789d63

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

design-docs/error_handling.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
The C source code under the directory `src/` follows this convention regarding error handling:
2+
3+
Functions that can return a failure to the caller, take the argument
4+
`libcrun_error_t *err` and return an int or a pointer.
5+
6+
If the function succeeds, then
7+
8+
- `0` or a non-NULL pointer is returned.
9+
- `err` is not modified.
10+
11+
If the function fails, then
12+
13+
- a negative number or a non-NULL pointer is returned.
14+
- `err` is set to the pointer of an allocated `struct libcrun_error_s`.
15+
The member `status` is set to an errno-style value.
16+
The member `msg` is set to an allocated error message string.
17+
18+
The functions expect that the passed in `err` is not already pointing to an allocated `struct libcrun_error_s`.

0 commit comments

Comments
 (0)