r8758 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r8757‎ | r8758 | r8759 >
Date:08:09, 30 April 2005
Author:eloquence
Status:old
Tags:
Comment:
show graphical error boxes when dying
Modified paths:
  • /trunk/extensions/ee/ee.pl (modified) (history)

Diff [purge]

Index: trunk/extensions/ee/ee.pl
@@ -24,6 +24,7 @@
2525 $cfgfile=$ENV{HOME}."/.ee-helper/ee.ini";
2626
2727 $DEBUG=0;
 28+$NOGUIERRORS=0;
2829 $LANGUAGE="de";
2930
3031 # Read config
@@ -33,7 +34,7 @@
3435 my $args=join(" ",@ARGV);
3536
3637 # Where do we store our files?
37 -my $tempdir=$cfg->val("Settings","Temp Path") or die _("notemppath",$cfgfile);
 38+my $tempdir=$cfg->val("Settings","Temp Path") or vdie (_("notemppath",$cfgfile));
3839
3940 # Remove slash at the end of the directory name, if existing
4041 $/="/";
@@ -55,7 +56,7 @@
5657 if(-e $args) {
5758 $input = new Config::IniFiles( -file => $args );
5859 } else {
59 - die _("nocontrolfile");
 60+ vdie (_("nocontrolfile"));
6061 }
6162
6263 # Initialize the browser as Firefox 1.0 with new cookie jar
@@ -99,15 +100,15 @@
100101 } elsif($type eq "Diff text") {
101102 $secondurl=$input->val("File 2","URL");
102103 if(!$secondurl) {
103 - die _("twofordiff");
 104+ vdie (_("twofordiff"));
104105 }
105106 $diffcommand=$cfg->val("Settings","Diff");
106107 if(!$diffcommand) {
107 - die _("nodifftool");
 108+ vdie (_("nodifftool"));
108109 }
109110 } else {
110111 # Nothing we know!
111 - die _("unknownprocess");
 112+ vdie (_("unknownprocess"));
112113 }
113114
114115
@@ -138,12 +139,15 @@
139140 }
140141
141142 # Log into server
 143+# Note that we also log in for diffs, as the raw text might only be available
 144+# to logged in users (depending on the wiki security settings), and we may want
 145+# to offer GUI-based rollback functionality later
142146 $response=$browser->post($login_url,@ns_headers,
143147 Content=>[wpName=>$username,wpPassword=>$password,wpRemember=>"1",wpLoginAttempt=>"Log in"]);
144148
145149 # We expect a redirect after successful login
146150 if($response->code!=302 && !$ignore_login_error) {
147 - die _("loginfailed",$login_url,$username,$password);
 151+ vdie (_("loginfailed",$login_url,$username,$password));
148152 }
149153
150154 $response=$browser->get($fileurl);
@@ -293,7 +297,7 @@
294298 my $summary=$entry->get_text();
295299 # Spam the summary if room is available :-)
296300 if(length($summary)<190) {
297 - my $tosummary="using [[Help:External editors|an external editor]]";
 301+ my $tosummary=_("usingexternal");
298302 if(length($summary)>0) {
299303 $tosummary=" [".$tosummary."]";
300304 }
@@ -390,6 +394,30 @@
391395 return $msg;
392396 }
393397
 398+sub vdie {
 399+
 400+my $errortext=shift;
 401+if(!$NOGUIERRORS) {
 402+ errorbox($errortext);
 403+}
 404+die($errortext);
 405+
 406+}
 407+
 408+sub errorbox {
 409+
 410+my $errortext=shift;
 411+
 412+my $dialog = Gtk2::MessageDialog->new ($window,
 413+ [qw/modal destroy-with-parent/],
 414+ 'error',
 415+ 'ok',
 416+ $errortext);
 417+$dialog->run;
 418+$dialog->destroy;
 419+
 420+}
 421+
394422 sub initmsg {
395423
396424 %messages=(
@@ -485,6 +513,11 @@
486514 entersummary_de=>
487515 "Zusammenfassung eingeben",
488516
 517+usingexternal=>
 518+"using [[Help:External editors|an external editor]]",
 519+usingexternal_de,
 520+"mit [[Hilfe:Externe Editoren|externem Editor]]",
 521+
489522 );
490523
491524 }
\ No newline at end of file

Status & tagging log