@@ -238,6 +238,22 @@ sub mw_connect_maybe {
238238 }
239239}
240240
241+ sub fatal_mw_error {
242+ my $action = shift ;
243+ print STDERR " fatal: could not $action .\n " ;
244+ print STDERR " fatal: '$url ' does not appear to be a mediawiki\n " ;
245+ if ($url =~ / ^https/ ) {
246+ print STDERR " fatal: make sure '$url /api.php' is a valid page\n " ;
247+ print STDERR " fatal: and the SSL certificate is correct.\n " ;
248+ } else {
249+ print STDERR " fatal: make sure '$url /api.php' is a valid page.\n " ;
250+ }
251+ print STDERR " fatal: (error " .
252+ $mediawiki -> {error }-> {code } . ' : ' .
253+ $mediawiki -> {error }-> {details } . " )\n " ;
254+ exit 1;
255+ }
256+
241257# # Functions for listing pages on the remote wiki
242258sub get_mw_tracked_pages {
243259 my $pages = shift ;
@@ -290,10 +306,7 @@ sub get_mw_all_pages {
290306 aplimit => ' max'
291307 });
292308 if (!defined ($mw_pages )) {
293- print STDERR " fatal: could not get the list of wiki pages.\n " ;
294- print STDERR " fatal: '$url ' does not appear to be a mediawiki\n " ;
295- print STDERR " fatal: make sure '$url /api.php' is a valid page.\n " ;
296- exit 1;
309+ fatal_mw_error(" get the list of wiki pages" );
297310 }
298311 foreach my $page (@{$mw_pages }) {
299312 $pages -> {$page -> {title }} = $page ;
@@ -316,10 +329,7 @@ sub get_mw_first_pages {
316329 titles => $titles ,
317330 });
318331 if (!defined ($mw_pages )) {
319- print STDERR " fatal: could not query the list of wiki pages.\n " ;
320- print STDERR " fatal: '$url ' does not appear to be a mediawiki\n " ;
321- print STDERR " fatal: make sure '$url /api.php' is a valid page.\n " ;
322- exit 1;
332+ fatal_mw_error(" query the list of wiki pages" );
323333 }
324334 while (my ($id , $page ) = each (%{$mw_pages -> {query }-> {pages }})) {
325335 if ($id < 0) {
0 commit comments