Parrot's exceptions have a 'severity' attribute to indicate, of course, how severe the exception is. The current severities are: (taken from runtime/parrot/include/except_severity.pasm
EXCEPT_NORMAL
EXCEPT_WARNING
EXCEPT_ERROR
EXCEPT_SEVERE
EXCEPT_FATAL
EXCEPT_DOOMED
EXCEPT_EXIT
For a long time now, the spec has said that non-fatal exceptions shouldn't cause termination of the program, but should result in the message being printed and normal execution resuming. This hasn't been the case until today. It was a pretty simple change, but should make some things much nicer in the future.
Here's a simple program demonstrating this behaviour:
.include 'include/except_severity.pasm'
.sub main :main
say 'before the warning'
$P0 = new 'Exception'
$P0['severity'] = .EXCEPT_WARNING
$P0['message'] = "\tOMG something is kinda wrong"
throw $P0
say 'after the warning'
.end
And here's the output:
[sweeks@kweh parrot]$ ./parrot et.pir
before the warning
OMG something is kinda wrong
after the warning
I've also updated Perl 6's warn() to use a non-fatal exception, meaning that these can now be caught.

Leave a comment