Skip to content

Conversation

@eriksjolund
Copy link
Contributor

@eriksjolund eriksjolund commented Dec 12, 2025

WIP (work-in-progress)

Note, not all crun source code follows the suggested error handling convention
For example

where a negative value is returned but there is no allocated libcrun_error_s (in line 1571).

Closes: #1860

Summary by Sourcery

Documentation:

  • Add a design document describing standard error handling patterns and expectations for libcrun_error_t-based APIs, including success/failure semantics and known exceptions.

Closes: containers#1860

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 12, 2025

Reviewer's Guide

Adds a new design document describing the standard error-handling conventions for C source files under src/, including expected function signatures, success/failure return patterns, and libcrun_error_s usage, with a placeholder section for documented exceptions.

File-Level Changes

Change Details Files
Introduce design documentation for C error-handling conventions using libcrun_error_t and libcrun_error_s.
  • Create a new error_handling.md design document under design-docs/
  • Specify the required function signature pattern using libcrun_error_t *err and int/pointer returns for functions that can fail
  • Define success semantics: return 0 or non-NULL pointer and leave the err argument untouched
  • Define failure semantics: return negative value or non-NULL pointer and set err to an allocated libcrun_error_s with errno-style status and allocated message
  • Clarify that err must not point to an already allocated libcrun_error_s
  • Add a placeholder section to later enumerate exceptions to these conventions
design-docs/error_handling.md

Assessment against linked issues

Issue Objective Addressed Explanation
#1860 Document the error handling convention used in the crun C source code (for functions taking libcrun_error_t *err), including how return values relate to error creation and the expectation that callers do not pass an already-created error object.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@giuseppe
Copy link
Member

Thanks for tackling this one!

Do you think we could also add an AGENTS.md file that links to this file?

@packit-as-a-service
Copy link

TMT tests failed. @containers/packit-build please check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document error handling convention

2 participants