|
ru.perl- RU.PERL ---------------------------------------------------------------------- From : Alexey Mahotkin 2:5020/400 10 Dec 2002 21:21:56 To : All Subject : [patch] обработка ОО-исключений в присутствии CGI::Carp -------------------------------------------------------------------------------- people, http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-12/msg00238.html [patch] fix handling of die($obj) in CGI::Carp * From: Alexey Mahotkin <alexm@hsys.msk.ru> * To: perl5-porters@perl.org * Cc: lstein@cshl.org * Date: Sun, 8 Dec 2002 21:55:01 +0300 (MSK) * Message-ID: <15859.38277.360403.718489@tyranny.hsys.msk.ru> I'm using object-oriented exceptions via die, and CGI::Carp stands in the way. Inside the sub die{} it messes around with the $message argument, adding " at file $file line $line", timestamps, etc. I believe that it only should do so if the '$message' (which is not always a "message") is !ref(). The "ineval" test in first line of sub die{} does not work (because my $obj is does not match the regex). I believe that the following patch (against 5.8.0) fixes the problem: =================================================================== RCS file: Carp.pm,v retrieving revision 1.1 diff -u -r1.1 Carp.pm - --- lib/CGI/Carp.pm 2002/12/08 18:41:05 1.1 +++ lib/CGI/Carp.pm 2002/12/08 18:45:19 @@ -369,14 +369,16 @@ sub die { realdie @_ if ineval; - my ($message) = @_; - my $time = scalar(localtime); - my($file,$line,$id) = id(1); - $message .= " at $file line $line." unless $message=~/\n$/; - &fatalsToBrowser($message) if $WRAP; - my $stamp = stamp; - $message=~s/^/$stamp/gm; - realdie $message; + my ($arg) = @_; + if (!ref($arg)) { + my $time = scalar(localtime); + my($file,$line,$id) = id(1); + $arg .= " at $file line $line." unless $arg=~/\n$/; + &fatalsToBrowser($arg) if $WRAP; + my $stamp = stamp; + $arg=~s/^/$stamp/gm; + } + realdie $arg; } sub set_message { (The '$message' is renamed to '$arg'; various additions are done only for the simple scalars). --alexm --- ifmail v.2.15dev5 * Origin: tyranny (2:5020/400) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.perl/169845c82f861.html, оценка из 5, голосов 10
|