Skip to content

Document error handling convention #1860

@eriksjolund

Description

@eriksjolund

Document the error handling convention used in the crun source code. The documentation could for example be added to the file CONTRIBUTING.md or some new file.

Just to give an idea what I'm thinking about, here is a sketch:

  • a function that takes an argument libcrun_error_t *err and returns a negative return value,
    creates an error in err. The function does not check if a previously created error is overwritten.
    To avoid a memory leak, callers of the function should thus pass in an err that has not already been created.

  • a function that takes an argument libcrun_error_t *err and returns a non-negative return value,
    does not create an error in err.

By having such error handing convention, the last line
in the following code would be unnecessary:

libcrun_error_t tmp_err = NULL;
ret = some_crun_function (&tmp_err);
if (ret < 0) {
   if (tmp_err != NULL) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions