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 28, 2013, 18:07 UTC
Message-ID
<20130528180727.GB21210@sigill.intra.peff.net>
In-Reply-To
<1369339503-12426-1-git-send-email-Matthieu.Moy@imag.fr>
On Thu, May 23, 2013 at 10:05:03PM +0200, Matthieu Moy wrote:
Show 5 quoted lines
> My use-case is an invalid SSL certificate. Pulling from the wiki with a
> recent version of libwww-perl fails, and git-remote-mediawiki gave no
> clue about the reason. Give the mediawiki API detailed error message, and
> since it is not so informative, hint the user about an invalid SSL
> certificate on https:// urls.

This is definitely an improvement, but it seems like it just the tip of the iceberg.

The call in get_mw_tracked_categories already uses die() with the MW error code and detailed string. Good. The call you fix here prints a guess to stderr and exits 1, and your patch improves that. But the call in get_mw_first_pages does the same broken thing, and is not fixed. Ditto for get_all_mediafiles. Other calls do not even seem to error check the result at all, and assume the result is not undef (which I suspect would produce a perl runtime error).

I wonder if we can do something like:
  our $mw_operation;
  $mediawiki->{config}->{on_error} = sub {
          my $err = "fatal: ";
          if (defined $mw_operation) {
                  $err .= "unable to $mw_operation: ";
          }
          err .= $mediawiki->{error}->{details};
          die "$err\n";
  };

and then callers do not have to worry about error-checking at all. If they want a nicer human-readable indication of where the error occured, they can do:

  local $mw_operation = "get the list of remote wiki pages";
  my $mw_pages = $mediawiki->list(...);
-Peff
Previous: Matthieu MoyNext: Matthieu Moy
Message 2 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.