Commits

Anonymous committed eafe4d5

Got rid of using Error.pm.

Comments (0)

Files changed (4)

installer/INSTALL

 
 * The Following Perl 5 CPAN Modules:
     - Config::IniFiles
-    - Error
     - MIME::Types
     - HTML::Hard::Disk
 

installer/perl5/Shlomif/Arad/Object.pm

 package Shlomif::Arad::Object;
 
 use strict;
+use warnings;
 
 sub new
 {

installer/perl5/Shlomif/Quad/Pres/CmdLine.pm

 use English;
 use Pod::Usage;
 use Cwd;
-use Error qw(:try);
 use Data::Dumper;
 use File::Copy;
 use File::Path ();
 
     if (!defined($cmd_line))
     {
-        throw $error_class -text => "cmd_line not specified";
+        $error_class->throw({text => 'cmd_line not specified'});
     }
 
     $self->cmd_line($cmd_line);
 
     if ($cmd_ret != 0)
     {
-        throw $error_class -text => $error_text;
+        $error_class->throw({text => $error_text});
     }
 
     return 0;
     my $self = shift;
 
     my $ret;
-    try {
+    eval {
         $ret = $self->real_run();
+    };
+
+    if (my $E = $@)
+    {
+        if (blessed($E) && $E->isa($error_class))
+        {
+            print STDERR "Quad-Pres Error: ", $E->text(), "\n";
+        }
+        else
+        {
+            print STDERR "$E\n"; 
+        }
+        $ret = -1;
     }
-    catch $error_class with {
-        my $e = shift;
-        print STDERR "Quad-Pres Error: ", $e->text(), "\n";
-        $ret = -1;        
-    }
-    otherwise {
-        my $e = shift;
-        print STDERR "$e\n"; 
-        $ret = -1;
-    };
 
     return $ret;
 }
 
     if (! exists($cmd_aliases{$command}))
     {
-        throw $error_class -text => "Unknown Command \"$command\"!";
+        $error_class->throw({text => "Unknown Command \"$command\"!"});
     }
     
     my $callback = $registered_commands{$cmd_aliases{$command}};
         {
             return $args->{empty_cb}->();
         }
-        throw $error_class -text => $args->{error_text};
+        $error_class->throw({text => $args->{error_text} });
     }
 
     return shift(@{$self->cmd_line()});
 
     if (!defined($args{"server_dest_dir"}))
     {
-        throw $error_class -text => "You must specify --dest-dir with somthing meaningful!";
+        $error_class->throw(
+            {text => 'You must specify --dest-dir with somthing meaningful!'}
+        );
     }
 
-    mkdir($src_dir_name) || throw $error_class -text => "Could not create the source directory.\nErrno=$!";
+    if (! mkdir($src_dir_name) )
+    {
+        $error_class->throw({
+                text => "Could not create the source directory.\nErrno=$!"
+            }
+        );
+    }
 
     open INI, ">$src_dir_name/quadpres.ini";
 
         $levels_num++;
         if (getcwd() eq "/")
         {
-            throw $error_class -text => "Could not find the Quad-Pres root anywhere";
+            $error_class->throw(
+                {
+                    text => 'Could not find the Quad-Pres root anywhere',
+                }
+            );
         }
     }
 
 
     if (! @$cmd_line)
     {
-        throw $error_class -text => "render must be followed by filenames or flags";
+        $error_class->throw(
+            { text => 'render must be followed by filenames or flags' }
+        );
     }
     
     my $render_all = 0;
     
     if (! $render_all)
     {
-        throw $error_class -text => "Don't know how to render anything but all yet.";
+        $error_class->throw(
+            { text => "Don't know how to render anything but all yet.", }
+        );
     }
 
     $self->chdir_to_base();
     $self->_render_all_contents();
     };
     my $error = $@;
-    if (defined($error) && blessed($error) && $error->isa('Shlomif::Quad::Pres::Exception::RenderFile'))
+    if ($error && blessed($error) && $error->isa('Shlomif::Quad::Pres::Exception::RenderFile'))
     {
-        throw $error_class -text => "Rendering Failed!";
+        $error_class->throw({text => "Rendering Failed!"});
     }
     
     # $self->run_command(
 
     if (! @$cmd_line)
     {
-        throw $error_class -text => "clear must be followed by filenames or flags";
+        $error_class->throw(
+            {text => 'clear must be followed by filenames or flags',}
+        );
     }
     
     my $clear_all = 0;
    
     if (! $clear_all)
     {
-        throw $error_class -text => "Don't know how to clear anything but all yet.";
+        $error_class->throw(
+            {text => q{Don't know how to clear anything but all yet.},}
+       );
     }
 
     # Go to the base dir.
         {
             if (! @path)
             {
-                throw $error_class -text => "Path given exits from the lecture ssource code base directory";
+                $error_class->throw(
+                    {
+                        text => 
+                        ('Path given exits from the lecture source'
+                        . ' code base directory'),
+                    }
+                );
             }
             else
             {
 
     if ($file_path->[0] ne "src")
     {
-        throw $error_class 
-            -text => "Cannot add files outside the src directory";
+        $error_class->throw(
+            {text => "Cannot add files outside the src directory",},
+        );
     }
 
     # Remove "src" from the file path
 
     if (! -e $filename)
     {
-        throw $error_class
-            -text => "File \"$filename\" does not exist";
+        $error_class->throw({
+                text => "File \"$filename\" does not exist"
+            }
+        );
     }
 
     require Contents;
         }
         if (!defined($next_section))
         {
-            throw $error_class
-                -text => ("Could not find the relevant section in the lecture's"
-                . " table of contents"
-                );                
+            $error_class->throw(
+                {
+                    text => ("Could not find the relevant section in "
+                        . "the lecture's table of contents"
+                    )
+                }
+            );
         }
         $current_section = $next_section;
     }
     my $last_component = $file_path->[$#$file_path];
     if ($last_component !~ /\.wml$/)
     {
-        throw $error_class
-            -text => "The Filename \"$last_component\" is not a slide.";
+        $error_class->throw({
+                text => "The Filename \"$last_component\" is not a slide."
+            }
+        );
     }
     $last_component =~ s/\.wml$//;
     if ( (grep { $_->{'url'} eq $last_component } @{$current_section->{'subs'}})
        || (grep { $_ eq $last_component } @{$current_section->{'images'}}))
     {
-        throw $error_class
-            -text => "The File already exists in the lecture.";
+        $error_class->throw(
+            {
+                text => "The File already exists in the lecture.",
+            }
+        );
     }
     my $is_dir = (-d $filename);
     my $title = "My Title";

installer/perl5/Shlomif/Quad/Pres/Exception.pm

 package Shlomif::Quad::Pres::Exception;
 
-use vars qw(@ISA);
+use strict;
+use warnings;
 
-use Error;
+use base 'Shlomif::Gamla::Object';
 
-@ISA=qw(Error);
+sub throw
+{
+    my $class = shift;
+    my $args = shift;
+
+    my $exception = $class->new();
+    $exception->{'text'} = $args->{text};
+
+    die $exception;
+}
+
+sub text
+{
+    my $self = shift;
+
+    return $self->{'text'};
+}
 
 package Shlomif::Quad::Pres::Exception::RenderFile;
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.