git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Urlichs <smurf@smurf.noris.de>
To: git@vger.kernel.org
Subject: Re: [RFC] Cleaning up die() error messages
Date: Tue, 11 Oct 2005 21:48:08 +0200	[thread overview]
Message-ID: <pan.2005.10.11.19.48.04.675482@smurf.noris.de> (raw)
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

  reply	other threads:[~2005-10-11 19:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-10 10:50 [RFC] Cleaning up die() error messages Elfyn McBratney
2005-10-10 19:04 ` Junio C Hamano
2005-10-11 19:48   ` Matthias Urlichs [this message]
2005-10-11 20:50     ` H. Peter Anvin
2005-10-12  1:20       ` Matthias Urlichs
2005-10-12  3:18         ` H. Peter Anvin
2005-10-12  4:25           ` Junio C Hamano
2005-10-12  4:40             ` H. Peter Anvin
2005-10-12  5:02               ` Junio C Hamano
2005-10-12  6:04           ` Matthias Urlichs
2005-10-10 20:14 ` Daniel Barkalow
2005-10-11 15:02 ` Alex Riesen
2005-10-11 16:11   ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pan.2005.10.11.19.48.04.675482@smurf.noris.de \
    --to=smurf@smurf.noris.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).