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

Re: [PATCH] git-remote-mediawiki: better error message when HTTP(S) access fails

From
Jeff King <peff@peff.net>
Date
May 29, 2013, 15:22 UTC
Message-ID
<20130529152216.GA9072@sigill.intra.peff.net>
In-Reply-To
<vpqzjvej8p4.fsf@anie.imag.fr>
On Wed, May 29, 2013 at 02:01:59PM +0200, Matthieu Moy wrote:
Show 11 quoted lines
> > 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
Previous: Jeff King
Message 6 of 6 in “git-remote-mediawiki: better error message when HTTP(S) access fails”
  1. git-remote-mediawiki: better error message when HTTP(S) access failsMatthieu Moy, May 23, 2013
  2. Jeff KingMay 28, 2013
  3. Matthieu MoyMay 29, 2013
  4. git-remote-mediawiki: better error message when HTTP(S) access failsMatthieu Moy, May 29, 2013
  5. Jeff KingMay 29, 2013
  6. Jeff KingMay 29, 2013

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.