RE: RFC: error codes on exit
- From
Felipe Contreras <felipe.contreras@gmail.com>
- Date
- May 20, 2021, 00:40 UTC
- Message-ID
- <60a5afeeb13b4_1d8f2208a5@natae.notmuch>
- In-Reply-To
- <YKWggLGDhTOY+lcy@google.com>
Jonathan Nieder wrote:
Show 13 quoted lines
> The API could look something like
>
> --- a/cache.h
> +++ b/cache.h
> @@ -590,6 +590,15 @@ int is_git_directory(const char *path);
> */
> int is_nonbare_repository_dir(struct strbuf *path);
>
> +enum git_error_code {
> + /*
> + * Not an error (= HTTP 200)
> + */
> + OK = 0,It's good to not include many initial codes, but I would start with at least three:
OK = 0, UNKNOWN = 1, NORMAL = 2,
die() could be mapped to UNKNOWN.
> +}; > +NORETURN void fatal(enum git_error_code code, const char *err, ...) > + __attribute__((format (printf, 2, 3))); > +
fatal() for me sounds 1) very dramatic, 2), not a verb, 3) and not a complete thing (fatal what?)
I would prefer "fail", or "fault", or anything that is a verb.
> Thoughts? Good idea? Bad idea?
Great idea.
-- Felipe Contreras