Hi Alex
On 30 Nov 2006, at 09:15, Alexander Ross wrote:
I've just committed an improved PerlMate. PerlMate now causes perl to load exception_handler.pm before executing the user code. exception_handler.pm overrides CORE::GLOBAL::die to format unhandled exceptions and print them to the file descriptor given by the environment varibale TM_ERROR_FD. This let's us manipulate the actual exception objects instead of just their string representations.
The implementation is very basic, as I have no actual Perl programming experience. But it handles `die "Sometext";` just fine. I don't know how it will react to the throwing of except objects.
I just checked your exception handler. It works fine as long as you use 'die' mot in a 'eval' environment. In Perl you often write your own handler like this:
Example: _______________________ #!/usr/bin/perl -w
$a = 5; $b = -1;
eval { $c = $a / $b; die "Denominator cannot be negative" if ($b < 0); };
print "Run-time error: $@"; _________________________
If I run this the 'die' output never reaches your exception handler because of
if($^S) { CORE::die($@); }...
Perl's $@ refers now to exception_handler.pm line 34 and this is not what I want to see.
Why did you choose this 'if clause' to call CORE::die?
If you leave it out and take only the else clause it works. (?)
On the other hand you have a small typo in line 55 of exception_handler.pm
corrected: print TM_ERROR_FD '<tr><td>in <a href="txmt://open?' . $url . '&line=' . $line . '"> ' . $display_name . "</a> at line $line<td></ tr>\n" ;
because:
print '$line' will print "$line" not the content of the variable $line.
###########
I wrote a small error/warning formatter in my posted perlmate.rb. Would it better to use TM_ERROR_FD instead of
class PerlMate < ScriptMate def filter_stderr(str) ... ?
-Hans