Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions design-docs/error_handling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
The C source code under the directory `src/` follows this convention regarding error handling:

Functions that can return a failure to the caller, take the argument
`libcrun_error_t *err` and return an int or a pointer.

If the function succeeds, then

- `0` or a non-NULL pointer is returned.
- `err` is not modified.

If the function fails, then

- a negative number or a non-NULL pointer is returned.
- `err` is set to the pointer of an allocated `struct libcrun_error_s`.
The member `status` is set to an errno-style value.
The member `msg` is set to an allocated error message string.

The functions expect that the passed in `err` is not already pointing to an allocated `struct libcrun_error_s`.