Skip to content

Createrepo_c Error Reporting

Tomas Mlcoch edited this page Sep 9, 2013 · 7 revisions

Error Domains

Error Codes

Summary about errors

  • Programming errors are not reported by GError (createrepo_c lib uses asserts to prevent programming errors).
  • NULL could be safely passed instead of GError** for every createrepo_c lib function.
  • If an error is reported via GError then output param(s) shoud be empty (e.g. NULL value).
  • If GError is used, it MUST be initialized to NULL (GError *err = NULL).

Example of usage

cr_Package *pkg;
GError *err = NULL;   // It's necessary to set err to NULL!

cr_package_parser_init();
pkg = cr_package_from_rpm("foopkg.rpm",
                          CR_SHA256,
                          "packages/foopkg.rpm",
                          NULL,
                          5,
                          NULL,
                          &err);
cr_package_parser_cleanup();
if (err != NULL) {
    printf("Error occured: %d (%s)", err->code, err->msg);
    g_error_free(err);
    return 1;
}
return 0;