git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] Cleaning up die() error messages

From
Matthias Urlichs <smurf@smurf.noris.de>
Date
Oct 11, 2005, 19:48 UTC
Message-ID
<pan.2005.10.11.19.48.04.675482@smurf.noris.de>
In-Reply-To
<7vzmph42j2.fsf@assigned-by-dhcp.cox.net>
Hi, Junio C Hamano wrote:
> One thing to keep in mind is how badly this C part might
> interact with the libification effort going on underwater.
Not too badly.
> Since current code Smurf is working on is based on 0.99.6 and
I've merged it up once already; will do that again soon.
> many small pieces need to be reviewed anyway, I am not so much
> worried about forward porting the changes.  

I've also mostly succeeded in keeping the individual patches clean so that everything still builds (and verifies), so it might be easiest to just merge with it. ;-)

But we'll cross that bridge when we get to it.
>                             But some die()s that
> are in the parts that will be moved to the common library code
> would also want to use this prog global somehow.

IMHO, common library code should not be allowed to die. (Yes, that does imply replacing all the xmalloc() calls.)

My library effort has a buffer for the (first) error message. The caller can elect to suppress printing it, so that it can be formatted appropriately. Python, for instance, will wrap errors in an exception.

The way I structured it so far, a C program would do 
	git_env = git_env_new();
	die_if_null(git_env());
	git_env->print_error = 0;
[...]
	git_whatever(git_env, ...);
	if (git_env->error) {
		fprintf(stderr, "%s: doing whatever: %s\n",
			my_program_name, git_env->error);
		git_env_clear_error(git_env);
		goto whatever_bad_so_go_clean_up;
	}
-- 
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
 - -
A hundred mouths, a hundred tongues, And throats of brass, inspired with
iron lungs.
					-- Virgil
Previous: Junio C HamanoNext: H. Peter Anvin
Message 3 of 13 in “[RFC] Cleaning up die() error messages”
  1. Elfyn McBratneyOct 10, 2005
  2. Junio C HamanoOct 10, 2005
  3. Matthias UrlichsOct 11, 2005
  4. H. Peter AnvinOct 11, 2005
  5. Matthias UrlichsOct 12, 2005
  6. H. Peter AnvinOct 12, 2005
  7. Junio C HamanoOct 12, 2005
  8. H. Peter AnvinOct 12, 2005
  9. Junio C HamanoOct 12, 2005
  10. Matthias UrlichsOct 12, 2005
  11. Daniel BarkalowOct 10, 2005
  12. Alex RiesenOct 11, 2005
  13. H. Peter AnvinOct 11, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.