You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl-cvs@perl.apache.org by ri...@apache.org on 2005/02/27 23:16:42 UTC

cvs commit: embperl/xsbuilder/maps ep_structure.map

richter     2005/02/27 14:16:42

  Modified:    .        Changes.pod Embperl.pod MANIFEST TODO epdat2.h
                        epeval.c epmain.c test.pl
               podsrc   Config.spod
               xsbuilder/maps ep_structure.map
  Added:       test/cmp includeerr3.htm
               test/html incerrobj.htm includeerr3.htm
  Log:
     - If an object is passed to die inside Execute the errors array
       will receive this object and will not be stringified.
       Requested by Robert Noris.
     - $epreq -> errobj holds the last object passed to die during
       the request.
     - Added documentaion of Embperl's error handling and trapping.
  
  Revision  Changes    Path
  1.265     +6 -0      embperl/Changes.pod
  
  Index: Changes.pod
  ===================================================================
  RCS file: /home/cvs/embperl/Changes.pod,v
  retrieving revision 1.264
  retrieving revision 1.265
  diff -u -r1.264 -r1.265
  --- Changes.pod	27 Feb 2005 20:22:00 -0000	1.264
  +++ Changes.pod	27 Feb 2005 22:16:41 -0000	1.265
  @@ -28,6 +28,12 @@
        for example from mod_perl Authentication handler.
      - Fixed problem with undefined $req_rec when Embperl::Execute
        is called from a registry script. Reported by Martin Moss.     
  +   - If an object is passed to die inside Execute the errors array
  +     will receive this object and will not be stringified.
  +     Requested by Robert Noris.
  +   - $epreq -> errobj holds the last object passed to die during 
  +     the request.
  +   - Added documentaion of Embperl's error handling and trapping. 
   
   =head1 2.0rc2  21. November 2004
   
  
  
  
  1.88      +57 -0     embperl/Embperl.pod
  
  Index: Embperl.pod
  ===================================================================
  RCS file: /home/cvs/embperl/Embperl.pod,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- Embperl.pod	27 Feb 2005 20:05:47 -0000	1.87
  +++ Embperl.pod	27 Feb 2005 22:16:41 -0000	1.88
  @@ -31,6 +31,15 @@
   Advanced user can create their own syntax definitions (for example tag libraries)
   and extent Embperl by writing their own providers and much more
   
  +B<IMPORTANT:> This document describes the syntax and several features of Embperl.
  +Please read also L<perldoc Config.pod|Config.pod>, which describes how to
  +configure Embperl and how to access the different Embperl objects and 
  +there data. Also take a look at L<perldoc Embperl::Object|Embperl/Object.pod>
  +to learn how to use Embperl page as objects.
  +
  +Additionaly there are a few introductions documents should consider to read:
  +L<Intro.pod>, L<IntroEmbperl2.pod> and L<IntroEmbperlObject.pod>.
  +
   
   =head1 SYNTAX
   
  @@ -1413,7 +1422,55 @@
   with $r -> gettext('bar')
   
   
  +=head1 Error trapping
  +
  +When an error occurs inside an Embperl page, Embperl will display an error page,
  +containing the error message.
  +
  +Sometimes you want to have a different behaviour. One possibility is to let
  +Apache display a custom error page (of course only when you run under mod_perl).
  +
  +To get this working you need to set the option C<optReturnError> (262144)
  +in your httpd.conf in the C<EMBPERL_DEBUG> directive.
  +
  +With this option set, Embperl sends no output in case of an error.
  +It returns the error back to Apache or the calling program. When running
  +under mod_perl this gives you the chance to use the Apache I<ErrorDocument>
  +directive to show a custom error-document. Inside the ErrorDocument
  +you can retrieve the error messages with
   
  +  $errors = $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ;
  +
  +where C<$errors> is a array reference.
  +
  +If you want to trap exceptions in a Embperl document, that you call via Execute,
  +you can do this by passing an array to Execute, which receives all error/warning 
  +messages and/or all error objects.
  +
  +    [-
  +    Execute ({inputfile => 'foo.epl', errors => \@errors}) ;
  +    -]
  +    
  +    [$if @errors$]
  +        The following errors had occured:<br>
  +        [$foreach $err (@errors)$]
  +            [+ $err +]<br>         
  +        [$endforeach$]
  +    [$endif$]
  +
  +
  +In case you call C<die> inside the executed page and pass an object (or a reference) 
  +to C<die> instead of a string this will also show up in @errors. The last object 
  +passed to C<die> is also available via C<$epreq -> errobj>.
  +
  +C<$epreq -> error> can be used to test if an error occured so far during the
  +current request. You can also set C<$epreq -> error> to false to reset Embperl's
  +internal error condition.
  +
  +An more seldom used option is C<optDisableEmbperlErrorPage> (2), which tells
  +tells Embperl not to send its own errorpage in case of failure,
  +but instead show as much of the page as possible. Errors are only logged
  +to the log file.
   
   
   =head1 Utility Functions
  
  
  
  1.99      +3 -0      embperl/MANIFEST
  
  Index: MANIFEST
  ===================================================================
  RCS file: /home/cvs/embperl/MANIFEST,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- MANIFEST	14 Feb 2005 18:49:04 -0000	1.98
  +++ MANIFEST	27 Feb 2005 22:16:41 -0000	1.99
  @@ -281,6 +281,7 @@
   test/cmp/include.htm
   test/cmp/includeerr1.htm
   test/cmp/includeerr2.htm
  +test/cmp/includeerr3.htm
   test/cmp/includeerrbt.htm
   test/cmp/incperl.htm
   test/cmp/inctext.htm
  @@ -466,10 +467,12 @@
   test/html/importsub2.htm
   test/html/inc.htm
   test/html/incerr.htm
  +test/html/incerrobj.htm
   test/html/incif.htm
   test/html/include.htm
   test/html/includeerr1.htm
   test/html/includeerr2.htm
  +test/html/includeerr3.htm
   test/html/includeerrbt.htm
   test/html/incparam.htm
   test/html/incperl.htm
  
  
  
  1.133     +0 -4      embperl/TODO
  
  Index: TODO
  ===================================================================
  RCS file: /home/cvs/embperl/TODO,v
  retrieving revision 1.132
  retrieving revision 1.133
  diff -u -r1.132 -r1.133
  --- TODO	27 Feb 2005 20:22:00 -0000	1.132
  +++ TODO	27 Feb 2005 22:16:41 -0000	1.133
  @@ -9,12 +9,8 @@
   
   - check memory on recompile of epl files
   
  -- patches Angus
  -
   - make test fedora 1 [13.12.04]
   
  -- return object reference in @errors [Robert Norris 23.2.05]
  -
   - EmbperlObject and ErrorDocument [Robert Noris 24.2.05]
   
   
  
  
  
  1.9       +2 -1      embperl/epdat2.h
  
  Index: epdat2.h
  ===================================================================
  RCS file: /home/cvs/embperl/epdat2.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- epdat2.h	2 Apr 2004 05:10:41 -0000	1.8
  +++ epdat2.h	27 Feb 2005 22:16:41 -0000	1.9
  @@ -399,6 +399,7 @@
       char    errdat1 [ERRDATLEN] ; /* Additional error information */
       char    errdat2 [ERRDATLEN] ;
       char    lastwarn [ERRDATLEN] ; /* last warning */
  +    SV *    pErrSV ;               /* in case error is an object it is copied to here */
   
       AV *    pDomTreeAV ; /* holds all DomTrees alocated during the request */
       AV *    pCleanupAV ; /* set all sv's that are conatined in that array to undef after the whole request */
  
  
  
  1.37      +25 -2     embperl/epeval.c
  
  Index: epeval.c
  ===================================================================
  RCS file: /home/cvs/embperl/epeval.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- epeval.c	16 Aug 2004 07:36:15 -0000	1.36
  +++ epeval.c	27 Feb 2005 22:16:41 -0000	1.37
  @@ -80,7 +80,14 @@
            
   	/* LogError (r, rcEvalErr) ; */
   
  -	sv_setpv(pSVErr,"");
  +        if (SvROK (pSVErr))
  +            {
  +            if (r -> pErrSV)
  +                SvREFCNT_dec(r -> pErrSV) ;
  +            r -> pErrSV = newRV (SvRV(pSVErr)) ;
  +            }
  +        
  +        sv_setpv(pSVErr,"");
           return rcEvalErr ;
           }
   
  @@ -558,6 +565,14 @@
           if (l > 0 && r -> errdat1[l-1] == '\n')
                l-- ;
           r -> errdat1[l] = '\0' ;
  +
  +        if (SvROK (pSVErr))
  +            {
  +            if (r -> pErrSV)
  +                SvREFCNT_dec(r -> pErrSV) ;
  +            r -> pErrSV = newRV (SvRV(pSVErr)) ;
  +            }
  +        
            
   	LogError (r, rcEvalErr) ;
   
  @@ -842,6 +857,14 @@
           if (l > 0 && r -> errdat1[l-1] == '\n')
                l-- ;
           r -> errdat1[l] = '\0' ;
  +
  +        if (SvROK (pSVErr))
  +            {
  +            if (r -> pErrSV)
  +                SvREFCNT_dec(r -> pErrSV) ;
  +            r -> pErrSV = newRV (SvRV(pSVErr)) ;
  +            }
  +        
            
   	LogError (r, rcEvalErr) ;
   
  
  
  
  1.138     +2 -2      embperl/epmain.c
  
  Index: epmain.c
  ===================================================================
  RCS file: /home/cvs/embperl/epmain.c,v
  retrieving revision 1.137
  retrieving revision 1.138
  diff -u -r1.137 -r1.138
  --- epmain.c	25 Feb 2005 08:06:21 -0000	1.137
  +++ epmain.c	27 Feb 2005 22:16:42 -0000	1.138
  @@ -274,7 +274,7 @@
   
           if (r -> pErrArray)
               {
  -            av_push (r -> pErrArray, pSV) ;
  +            av_push (r -> pErrArray, r -> pErrSV?SvREFCNT_inc(r -> pErrSV):pSV) ;
               }
           else
   	    SvREFCNT_dec (pSV) ;
  
  
  
  1.152     +3 -0      embperl/test.pl
  
  Index: test.pl
  ===================================================================
  RCS file: /home/cvs/embperl/test.pl,v
  retrieving revision 1.151
  retrieving revision 1.152
  diff -u -r1.151 -r1.152
  --- test.pl	27 Feb 2005 20:05:47 -0000	1.151
  +++ test.pl	27 Feb 2005 22:16:42 -0000	1.152
  @@ -363,6 +363,9 @@
           'repeat'     => 2,
           'condition'  => '$] >= 5.006001', 
           },
  +    'includeerr3.htm' => { 
  +        'errors'     => 2,
  +        },
       'includeerrbt.htm' => { 
           'errors'     => 3,
           'version'    => 2,
  
  
  
  1.15      +7 -0      embperl/podsrc/Config.spod
  
  Index: Config.spod
  ===================================================================
  RCS file: /home/cvs/embperl/podsrc/Config.spod,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Config.spod	14 Feb 2005 18:49:04 -0000	1.14
  +++ Config.spod	27 Feb 2005 22:16:42 -0000	1.15
  @@ -1651,6 +1651,13 @@
   
   Last warning message.
   
  +=head2 *METHOD $request / / errobj / 2.0rc3 / yes
  +
  +The object passed to the last die, if any. 
  +This is usefully when you pass an object to die inside an Execute. After the Execute you
  +can check $epreq -> errobj, to get the object. The object is also push to the array
  +passed to the L<errors> parameter of Execute.
  +
   =head2 *METHOD $request / / cleanup_vars / 2.0b6 / yes
   
   Reference to an array which is filled with references to variables that should be
  
  
  
  1.1                  embperl/test/cmp/includeerr3.htm
  
  Index: includeerr3.htm
  ===================================================================
  
  <html>
  <head>
  <title>Embperl Tests - Errors in Include other Embperl pages via Execute 3</title>
  </head>
  
  <h1>Embperl Tests - Errors in Include other Embperl pages via Execute 3</h1>
  
  
  
  ^\*\*\*errors: \[\d+\]ERR:  24:  Error in Perl code: Can't locate object method &quot;is&quot; via package &quot;here&quot; \(perhaps you forgot to load &quot;here&quot;\?\) at .+\/test\/html\/incerr.htm line 6.<br>
  
  
  ***rc:0
  ***errors: #3<br>
  ^\*\*\*errors: \[\d+\]ERR:  24:  Error in Perl code: Can't locate object method &quot;is&quot; via package &quot;here&quot; \(perhaps you forgot to load &quot;here&quot;\?\) at .+test\/html\/incerr.htm line 6.
  
  ^\[\d+\]ERR:  32:  Warning in Perl code: Unquoted string &quot;testerrobj&quot; may clash with future reserved word at .+\/test\/html\/incerrobj.htm line 18.
  
  ^testerrobj=HASH\(0x
  ^\*\*\*errobj: testerrobj=HASH\(0x
  ***errobj msg: Error Message from Object<br>
  ***errors msg: Error Message from Object<br>
  
  
  </body>
  </html>
  
  
  
  1.1                  embperl/test/html/incerrobj.htm
  
  Index: incerrobj.htm
  ===================================================================
  [+ "Start include incerrobj" +]
  
  [!
  {
  package testerrobj ;
  
  sub new 
  
      { 
      return bless { msg => "Error Message from Object"} ;
      }
  
  }
  
  !]
  
  [-
  die testerrobj -> new () ;
  -]
  
  [+ "End include incerrobj" +]
  
  
  
  1.1                  embperl/test/html/includeerr3.htm
  
  Index: includeerr3.htm
  ===================================================================
  
  <html>
  <head>
  <title>Embperl Tests - Errors in Include other Embperl pages via Execute 3</title>
  </head>
  
  <h1>Embperl Tests - Errors in Include other Embperl pages via Execute 3</h1>
  
  
  
  [# cause runtime error #]
  [- Execute ( {inputfile => 'incerr.htm', param => ['err', 'main'], errors => \@errors}) -]
  
  
  ***errors: [+ "@errors" +]<br>
  
  
  [- $rc = Execute ( {inputfile => 'incerrobj.htm', errors => \@errors}) -]
  
  ***rc: [+ $rc +]
  ***errors: #[+ scalar(@errors) +]<br>
  ***errors: [+ join ("\n\n", @errors) +]<br>
  ***errobj: [- $e = $epreq -> errobj -][+ $e +]<br>
  ***errobj msg: [+ $epreq -> errobj?$epreq -> errobj -> {msg}:'<undef>' +]<br>
  ***errors msg: [+ ref $errors[-1]?$errors[-1] -> {msg}:'<undef>' +]<br>
  
  
  </body>
  </html>
  
  
  
  1.8       +2 -1      embperl/xsbuilder/maps/ep_structure.map
  
  Index: ep_structure.map
  ===================================================================
  RCS file: /home/cvs/embperl/xsbuilder/maps/ep_structure.map,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ep_structure.map	16 Aug 2004 04:19:45 -0000	1.7
  +++ ep_structure.map	27 Feb 2005 22:16:42 -0000	1.8
  @@ -43,7 +43,8 @@
      pErrArray | errors
      errdat1[ERRDATLEN] | errdat1
      errdat2[ERRDATLEN] | errdat2
  -   lastwarn[ERRDATLEN] | lastwarn
  +   lastwarn[ERRDATLEN] | lastwarn
  +   pErrSV | errobj
   !   pDomTreeAV | dom_tree_av
      pCleanupAV | cleanup_vars
      pCleanupPackagesHV | cleanup_packages
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-cvs-help@perl.apache.org