cvsuser     02/02/28 21:14:20

  Modified:    P5EEx/Blue/P5EEx/Blue/Context CGI.pm
  Log:
  added ability to catch exceptions during dispatch_events()
  
  Revision  Changes    Path
  1.6       +144 -124  p5ee/P5EEx/Blue/P5EEx/Blue/Context/CGI.pm
  
  Index: CGI.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/P5EEx/Blue/P5EEx/Blue/Context/CGI.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- CGI.pm    8 Feb 2002 20:48:08 -0000       1.5
  +++ CGI.pm    1 Mar 2002 05:14:20 -0000       1.6
  @@ -1,6 +1,6 @@
   
   #############################################################################
  -## $Id: CGI.pm,v 1.5 2002/02/08 20:48:08 spadkins Exp $
  +## $Id: CGI.pm,v 1.6 2002/03/01 05:14:20 spadkins Exp $
   #############################################################################
   
   package P5EEx::Blue::Context::CGI;
  @@ -363,6 +363,7 @@
       my ($self) = @_;
       my $cgi = $self->{cgi};
   
  +    eval {
       if (defined $cgi) {
           my ($session, $wname);
           $session = $self->{session};        # get the Session
  @@ -400,8 +401,8 @@
                   }
   
                   # Indexed vars: e.g. "table_editor{data}[1][5]"
  -                if ($var =~ /[\[\]\{\}]/) {
  -                    $session->set("Widget.$var", $value);
  +                    if ($var =~ /^([^\[\]\{\}]+)([\[\]\{\}].*)/) {
  +                        $self->wset($1, $2, $value);
                   }
                   else {
                       # check to see if the value should be multi-valued
  @@ -504,6 +505,25 @@
                   }
               }
           }
  +        }
  +    };
  +    if ($@) {
  +        my ($msg);
  +        if (ref($@) eq "") {  # i.e. a string thrown with "die"
  +            $msg = $@;
  +        }
  +        elsif ($@->isa("P5EEx::Blue::Exception")) {
  +            $msg = $@->error . "\n" . $@->trace->as_string . "\n";
  +        }
  +        else {
  +            $@->rethrow();
  +        }
  +        $msg =~ s{&}{&}gso;
  +        $msg =~ s{<}{&lt;}gso;
  +        $msg =~ s{>}{&gt;}gso;
  +        $msg =~ s{\"}{&quot;}gso;
  +        $msg =~ s{\n}{<br>\n}gso;
  +        $self->add_message($msg);
       }
   
       $self->display_current_widget();
  
  
  


Reply via email to