From 466d70bd1187419cd8daa4503653da58cb1b54d0 Mon Sep 17 00:00:00 2001
From: Benjamin Mako Hill <mako@atdot.cc>
Date: Sat, 12 Feb 2011 16:13:46 -0500
Subject: fix error reporting IRT UNIVERAL::isa

---
 bin/mvs |   38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/bin/mvs b/bin/mvs
index 2bd8505..5d54edd 100755
--- a/bin/mvs
+++ b/bin/mvs
@@ -86,23 +86,33 @@ sub main {
             if $opt_verbose >= 1;
     print $message unless $opt_verbose <= -1;
     eval { $wmc->$method(@files) };
-    if (UNIVERSAL::isa($@, 'WWW::Mediawiki::Client::Exception')) {
+
+    my $tmp_error = $@;
+
+    if (UNIVERSAL::isa($tmp_error, 'WWW::Mediawiki::Client::Exception')) {
         open (LOG, ">>$LOGFILE");
-        print LOG "\n-----------------\n$@";
-        warn "\n-----------------\n$@" if $opt_verbose >= 1;
-        if ($@->isa('WWW::Mediawiki::Client::LoginException')) {
-            print LOG Data::Dumper->Dump([$@->res], ['res'] ) . "\n";
-            print LOG Data::Dumper->Dump([$@->cookie_jar], ['cookie_jar']) . "\n";
+        print LOG "\n-----------------\n$tmp_error";
+        warn "\n-----------------\n$tmp_error" if $opt_verbose >= 1;
+
+        if (UNIVERSAL::isa($tmp_error, 'WWW::Mediawiki::Client::LoginException')) {
+            print LOG Data::Dumper->Dump([$tmp_error->res], ['res'] ) . "\n";
+            print LOG Data::Dumper->Dump([$tmp_error->cookie_jar], 
+					 ['cookie_jar']) . "\n";
             close LOG;
-            die $@->error . " See $LOGFILE for details.\n" ;
-        } elsif ($@->isa('WWW::Mediawiki::Client::CommitException')) {
-            print LOG Data::Dumper->Dump([$@->res], ['res']) . "\n";
-        } elsif ($@->isa('WWW::Mediawiki::Client::ServerPageException')) {
-            print LOG Data::Dumper->Dump([$@->res], ['res']) . "\n";
+            die $tmp_error->error . "See $LOGFILE for details.\n" ;
+        } elsif (UNIVERSAL::isa($tmp_error,
+				'WWW::Mediawiki::Client::CommitException')) {
+            print LOG Data::Dumper->Dump([$tmp_error->res], ['res']) . "\n";
+	    
+        } elsif (UNIVERSAL::isa($tmp_error,
+				'WWW::Mediawiki::Client::ServerPageException')) {
+            print LOG Data::Dumper->Dump([$tmp_error->res], ['res']) . "\n";
         }
-        warn $@->error . " See $LOGFILE for details.\n" ;
-    } elsif ($@) {
-	die $@;
+
+        warn $tmp_error->error, "\n", "See $LOGFILE for details.\n";
+
+    } elsif ($tmp_error) {
+	die $tmp_error->error;
     }
     return 1 unless $wmc->status;
     my %status = %{$wmc->status};
-- 
1.7.2.3

