{"action":"created","comment":{"url":"https://api.github.com/repos/snapcore/snap-confine/pulls/comments/90533209","pull_request_review_id":11052577,"id":90533209,"diff_hunk":"@@ -0,0 +1,128 @@\n+/*\n+ * Copyright (C) 2016 Canonical Ltd\n+ *\n+ * This program is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License version 3 as\n+ * published by the Free Software Foundation.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ *\n+ */\n+\n+#ifndef SNAP_CONFINE_ERROR_H\n+#define SNAP_CONFINE_ERROR_H\n+\n+/**\n+ * This module defines APIs for simple error management.\n+ *\n+ * Errors are allocated objects that can be returned and passed around from\n+ * functions.  Errors carry a formatted message and optionally a scoped error\n+ * code. The code is coped with a string \"domain\" that simply acts as a\n+ * namespace for various interacting modules.\n+ **/\n+\n+/**\n+ * Opaque error structure.\n+ **/\n+struct sc_error;\n+\n+/**\n+ * Error domain for errors related to system errno.\n+ **/\n+#define SC_ERRNO_DOMAIN \"errno\"\n+\n+/**\n+ * Initialize a new error object.\n+ *\n+ * The domain is a cookie-like string that allows the caller to distinguish\n+ * between \"namespaces\" of error codes. It should be a static string that is\n+ * provided by the caller. Both the domain and the error code can be retrieved\n+ * later.\n+ *\n+ * This function calls die() in case of memory allocation failure.\n+ **/\n+__attribute__ ((format(printf, 3, 4)))\n+struct sc_error *sc_error_init(const char *domain, int code, const char *msgfmt,\n+\t\t\t       ...);\n+\n+/**\n+ * Initialize an errno-based error.\n+ *\n+ * The error carries a copy of errno and a custom error message as designed by\n+ * the caller. See sc_error_init() for a more complete description.\n+ *\n+ * This function calls die() in case of memory allocation failure.\n+ **/\n+__attribute__ ((format(printf, 2, 3)))\n+struct sc_error *sc_error_init_from_errno(int errno_copy, const char *msgfmt,\n+\t\t\t\t\t  ...);\n+\n+/**\n+ * Get the error domain out of an error object.\n+ *\n+ * The error domain acts as a namespace for error codes. The return value must\n+ * not be released in any way.\n+ **/\n+const char *sc_error_domain(struct sc_error *err);\n+\n+/**\n+ * Get the error code out of an error object.\n+ *\n+ * The error code is scoped by the error domain.\n+ *\n+ * An error code of zero is special-cased to indicate that no particular error\n+ * code is reserved for this error and it's not something that the programmer\n+ * can rely on programmatically. This can be used to return an error message\n+ * without having to allocate a distinct code for each one.\n+ **/\n+int sc_error_code(struct sc_error *err);\n+\n+/**\n+ * Get the error message out of an error object.\n+ *\n+ * The error message is bound to the life-cycle of the error object.\n+ **/\n+const char *sc_error_msg(struct sc_error *err);\n+\n+/**\n+ * Free an error object.\n+ *\n+ * The error object can be NULL.\n+ **/\n+void sc_error_free(struct sc_error *error);\n+\n+/**\n+ * Cleanup an error with sc_error_free()\n+ *\n+ * This function is designed to be used with\n+ * __attribute__((cleanup(sc_cleanup_error))).\n+ **/\n+void sc_cleanup_error(struct sc_error **ptr);\n+\n+/**\n+ *\n+ * Die if there's an error.\n+ *\n+ * This function is a correct way to die() if the passed error is not NULL.\n+ *\n+ * The error message is derived from the data in the error, using the special\n+ * errno domain to provide additional information if that is available.\n+ **/\n+void sc_error_die(struct sc_error *error);","path":"src/error.h","position":117,"original_position":117,"commit_id":"287867e14403415273b14f99fa7a6e6159eeaf0d","original_commit_id":"287867e14403415273b14f99fa7a6e6159eeaf0d","user":{"login":"vosst","id":13215244,"avatar_url":"https://avatars.githubusercontent.com/u/13215244?v=3","gravatar_id":"","url":"https://api.github.com/users/vosst","html_url":"https://github.com/vosst","followers_url":"https://api.github.com/users/vosst/followers","following_url":"https://api.github.com/users/vosst/following{/other_user}","gists_url":"https://api.github.com/users/vosst/gists{/gist_id}","starred_url":"https://api.github.com/users/vosst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vosst/subscriptions","organizations_url":"https://api.github.com/users/vosst/orgs","repos_url":"https://api.github.com/users/vosst/repos","events_url":"https://api.github.com/users/vosst/events{/privacy}","received_events_url":"https://api.github.com/users/vosst/received_events","type":"User","site_admin":false},"body":"Maybe rename to sc_error_die_if.","created_at":"2016-12-01T20:43:21Z","updated_at":"2016-12-01T20:43:21Z","html_url":"https://github.com/snapcore/snap-confine/pull/199#discussion_r90533209","pull_request_url":"https://api.github.com/repos/snapcore/snap-confine/pulls/199","_links":{"self":{"href":"https://api.github.com/repos/snapcore/snap-confine/pulls/comments/90533209"},"html":{"href":"https://github.com/snapcore/snap-confine/pull/199#discussion_r90533209"},"pull_request":{"href":"https://api.github.com/repos/snapcore/snap-confine/pulls/199"}}},"pull_request":{"url":"https://api.github.com/repos/snapcore/snap-confine/pulls/199","id":96097177,"html_url":"https://github.com/snapcore/snap-confine/pull/199","diff_url":"https://github.com/snapcore/snap-confine/pull/199.diff","patch_url":"https://github.com/snapcore/snap-confine/pull/199.patch","issue_url":"https://api.github.com/repos/snapcore/snap-confine/issues/199","number":199,"state":"open","locked":false,"title":"Add error support code","user":{"login":"zyga","id":784262,"avatar_url":"https://avatars.githubusercontent.com/u/784262?v=3","gravatar_id":"","url":"https://api.github.com/users/zyga","html_url":"https://github.com/zyga","followers_url":"https://api.github.com/users/zyga/followers","following_url":"https://api.github.com/users/zyga/following{/other_user}","gists_url":"https://api.github.com/users/zyga/gists{/gist_id}","starred_url":"https://api.github.com/users/zyga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyga/subscriptions","organizations_url":"https://api.github.com/users/zyga/orgs","repos_url":"https://api.github.com/users/zyga/repos","events_url":"https://api.github.com/users/zyga/events{/privacy}","received_events_url":"https://api.github.com/users/zyga/received_events","type":"User","site_admin":false},"body":"This patch adds die()-like APIs that can carry error information around\r\nthe control flow. They are meant to provide richer error information  in\r\ncases where the error is not fatal and needs to be returned to the\r\ncaller. The APIs are 100% tested and also integrate with die() where\r\nappropriate().\r\n\r\nSigned-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>","created_at":"2016-12-01T14:21:11Z","updated_at":"2016-12-01T20:51:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6ab8c865d4ff87030a05ab9867a935288ea1cb6e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/snapcore/snap-confine/pulls/199/commits","review_comments_url":"https://api.github.com/repos/snapcore/snap-confine/pulls/199/comments","review_comment_url":"https://api.github.com/repos/snapcore/snap-confine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snapcore/snap-confine/issues/199/comments","statuses_url":"https://api.github.com/repos/snapcore/snap-confine/statuses/287867e14403415273b14f99fa7a6e6159eeaf0d","head":{"label":"snapcore:errors","ref":"errors","sha":"287867e14403415273b14f99fa7a6e6159eeaf0d","user":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars.githubusercontent.com/u/19532717?v=3","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"repo":{"id":59485230,"name":"snap-confine","full_name":"snapcore/snap-confine","owner":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars.githubusercontent.com/u/19532717?v=3","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snapcore/snap-confine","description":"Low-level tool for setting up and confining snap application processes","fork":false,"url":"https://api.github.com/repos/snapcore/snap-confine","forks_url":"https://api.github.com/repos/snapcore/snap-confine/forks","keys_url":"https://api.github.com/repos/snapcore/snap-confine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snapcore/snap-confine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snapcore/snap-confine/teams","hooks_url":"https://api.github.com/repos/snapcore/snap-confine/hooks","issue_events_url":"https://api.github.com/repos/snapcore/snap-confine/issues/events{/number}","events_url":"https://api.github.com/repos/snapcore/snap-confine/events","assignees_url":"https://api.github.com/repos/snapcore/snap-confine/assignees{/user}","branches_url":"https://api.github.com/repos/snapcore/snap-confine/branches{/branch}","tags_url":"https://api.github.com/repos/snapcore/snap-confine/tags","blobs_url":"https://api.github.com/repos/snapcore/snap-confine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snapcore/snap-confine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snapcore/snap-confine/git/refs{/sha}","trees_url":"https://api.github.com/repos/snapcore/snap-confine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snapcore/snap-confine/statuses/{sha}","languages_url":"https://api.github.com/repos/snapcore/snap-confine/languages","stargazers_url":"https://api.github.com/repos/snapcore/snap-confine/stargazers","contributors_url":"https://api.github.com/repos/snapcore/snap-confine/contributors","subscribers_url":"https://api.github.com/repos/snapcore/snap-confine/subscribers","subscription_url":"https://api.github.com/repos/snapcore/snap-confine/subscription","commits_url":"https://api.github.com/repos/snapcore/snap-confine/commits{/sha}","git_commits_url":"https://api.github.com/repos/snapcore/snap-confine/git/commits{/sha}","comments_url":"https://api.github.com/repos/snapcore/snap-confine/comments{/number}","issue_comment_url":"https://api.github.com/repos/snapcore/snap-confine/issues/comments{/number}","contents_url":"https://api.github.com/repos/snapcore/snap-confine/contents/{+path}","compare_url":"https://api.github.com/repos/snapcore/snap-confine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snapcore/snap-confine/merges","archive_url":"https://api.github.com/repos/snapcore/snap-confine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snapcore/snap-confine/downloads","issues_url":"https://api.github.com/repos/snapcore/snap-confine/issues{/number}","pulls_url":"https://api.github.com/repos/snapcore/snap-confine/pulls{/number}","milestones_url":"https://api.github.com/repos/snapcore/snap-confine/milestones{/number}","notifications_url":"https://api.github.com/repos/snapcore/snap-confine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snapcore/snap-confine/labels{/name}","releases_url":"https://api.github.com/repos/snapcore/snap-confine/releases{/id}","deployments_url":"https://api.github.com/repos/snapcore/snap-confine/deployments","created_at":"2016-05-23T13:29:44Z","updated_at":"2016-11-30T15:57:20Z","pushed_at":"2016-12-01T19:02:57Z","git_url":"git://github.com/snapcore/snap-confine.git","ssh_url":"git@github.com:snapcore/snap-confine.git","clone_url":"https://github.com/snapcore/snap-confine.git","svn_url":"https://github.com/snapcore/snap-confine","homepage":"","size":1468,"stargazers_count":8,"watchers_count":8,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":8,"forks":19,"open_issues":8,"watchers":8,"default_branch":"master"}},"base":{"label":"snapcore:master","ref":"master","sha":"19a7ebeafd1dd383d91b6e29f4719d5d38b7e1a2","user":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars.githubusercontent.com/u/19532717?v=3","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"repo":{"id":59485230,"name":"snap-confine","full_name":"snapcore/snap-confine","owner":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars.githubusercontent.com/u/19532717?v=3","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snapcore/snap-confine","description":"Low-level tool for setting up and confining snap application processes","fork":false,"url":"https://api.github.com/repos/snapcore/snap-confine","forks_url":"https://api.github.com/repos/snapcore/snap-confine/forks","keys_url":"https://api.github.com/repos/snapcore/snap-confine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snapcore/snap-confine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snapcore/snap-confine/teams","hooks_url":"https://api.github.com/repos/snapcore/snap-confine/hooks","issue_events_url":"https://api.github.com/repos/snapcore/snap-confine/issues/events{/number}","events_url":"https://api.github.com/repos/snapcore/snap-confine/events","assignees_url":"https://api.github.com/repos/snapcore/snap-confine/assignees{/user}","branches_url":"https://api.github.com/repos/snapcore/snap-confine/branches{/branch}","tags_url":"https://api.github.com/repos/snapcore/snap-confine/tags","blobs_url":"https://api.github.com/repos/snapcore/snap-confine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snapcore/snap-confine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snapcore/snap-confine/git/refs{/sha}","trees_url":"https://api.github.com/repos/snapcore/snap-confine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snapcore/snap-confine/statuses/{sha}","languages_url":"https://api.github.com/repos/snapcore/snap-confine/languages","stargazers_url":"https://api.github.com/repos/snapcore/snap-confine/stargazers","contributors_url":"https://api.github.com/repos/snapcore/snap-confine/contributors","subscribers_url":"https://api.github.com/repos/snapcore/snap-confine/subscribers","subscription_url":"https://api.github.com/repos/snapcore/snap-confine/subscription","commits_url":"https://api.github.com/repos/snapcore/snap-confine/commits{/sha}","git_commits_url":"https://api.github.com/repos/snapcore/snap-confine/git/commits{/sha}","comments_url":"https://api.github.com/repos/snapcore/snap-confine/comments{/number}","issue_comment_url":"https://api.github.com/repos/snapcore/snap-confine/issues/comments{/number}","contents_url":"https://api.github.com/repos/snapcore/snap-confine/contents/{+path}","compare_url":"https://api.github.com/repos/snapcore/snap-confine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snapcore/snap-confine/merges","archive_url":"https://api.github.com/repos/snapcore/snap-confine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snapcore/snap-confine/downloads","issues_url":"https://api.github.com/repos/snapcore/snap-confine/issues{/number}","pulls_url":"https://api.github.com/repos/snapcore/snap-confine/pulls{/number}","milestones_url":"https://api.github.com/repos/snapcore/snap-confine/milestones{/number}","notifications_url":"https://api.github.com/repos/snapcore/snap-confine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snapcore/snap-confine/labels{/name}","releases_url":"https://api.github.com/repos/snapcore/snap-confine/releases{/id}","deployments_url":"https://api.github.com/repos/snapcore/snap-confine/deployments","created_at":"2016-05-23T13:29:44Z","updated_at":"2016-11-30T15:57:20Z","pushed_at":"2016-12-01T19:02:57Z","git_url":"git://github.com/snapcore/snap-confine.git","ssh_url":"git@github.com:snapcore/snap-confine.git","clone_url":"https://github.com/snapcore/snap-confine.git","svn_url":"https://github.com/snapcore/snap-confine","homepage":"","size":1468,"stargazers_count":8,"watchers_count":8,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":8,"forks":19,"open_issues":8,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snapcore/snap-confine/pulls/199"},"html":{"href":"https://github.com/snapcore/snap-confine/pull/199"},"issue":{"href":"https://api.github.com/repos/snapcore/snap-confine/issues/199"},"comments":{"href":"https://api.github.com/repos/snapcore/snap-confine/issues/199/comments"},"review_comments":{"href":"https://api.github.com/repos/snapcore/snap-confine/pulls/199/comments"},"review_comment":{"href":"https://api.github.com/repos/snapcore/snap-confine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snapcore/snap-confine/pulls/199/commits"},"statuses":{"href":"https://api.github.com/repos/snapcore/snap-confine/statuses/287867e14403415273b14f99fa7a6e6159eeaf0d"}}}}
{"actor":{"display_login":"vosst"}}