From c789d6382bb0082754dd90554677f88ecf4f1fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Sj=C3=B6lund?= Date: Fri, 9 Jan 2026 08:42:30 +0100 Subject: [PATCH] Document error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: https://github.com/containers/crun/issues/1860 Signed-off-by: Erik Sjölund --- design-docs/error_handling.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 design-docs/error_handling.md diff --git a/design-docs/error_handling.md b/design-docs/error_handling.md new file mode 100644 index 0000000000..08863ab9bb --- /dev/null +++ b/design-docs/error_handling.md @@ -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`.