From: Jeff King <peff@peff.net>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] git-remote-mediawiki: better error message when HTTP(S) access fails
Date: Wed, 29 May 2013 11:22:16 -0400 [thread overview]
Message-ID: <20130529152216.GA9072@sigill.intra.peff.net> (raw)
In-Reply-To: <vpqzjvej8p4.fsf@anie.imag.fr>
On Wed, May 29, 2013 at 02:01:59PM +0200, Matthieu Moy wrote:
> > I wonder if we can do something like:
> >
> > our $mw_operation;
> > $mediawiki->{config}->{on_error} = sub {
> > [...]
> > die "$err\n";
> > };
>
> Probably, but that would hardcode the fact that mediawiki errors are
> fatal, while in an ideal world, some errors should be recoverable, and
> some would require some cleanups before die-ing.
Fortunately this is perl, not C. We can catch and re-throw die
exceptions like:
my $mw_pages = eval { $mediawiki->list(...) };
if (!$mw_pages) {
# possibly continue to something else, or even...
clean_up();
die; # propagate $@
}
but it would require checking all of the call-sites. Another alternative
would be a wrapper function that each caller could opt into. But I
suspect the norm will be to die, so the exception model should make the
code cleaner.
> Also, an error during the first mediawiki operation should not
> necessarily have the same diagnosis hint as the others: if I just
> did a successfull querry, and the next fails, it can hardly be an SSL
> certificate error.
Yeah, my error template was just a sketch; I didn't look too carefully
at all of the callers, but the concept should be extensible.
> I'll send a v2 that covers a bit more (at least, push and pull with an
> invalid certificate both give the message).
Thanks.
-Peff
prev parent reply other threads:[~2013-05-29 15:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 20:05 [PATCH] git-remote-mediawiki: better error message when HTTP(S) access fails Matthieu Moy
2013-05-28 18:07 ` Jeff King
2013-05-29 12:01 ` Matthieu Moy
2013-05-29 12:06 ` [PATCH v2] " Matthieu Moy
2013-05-29 15:26 ` Jeff King
2013-05-29 15:22 ` Jeff King [this message]
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=20130529152216.GA9072@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).