Idea: 'throws' attribute for subs

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Greetings, colleagues!

I'm going to begin working on an extension, that would introduce an
attribute for subroutines, somewhat similar to Java's 'throws'.

It could like something like <<'__THE_FOLLOWING__':
use <TheModule>;
use Exception::Class (
    'Danger::Avalanche' => { isa => 'Danger' },
    'Danger::Tornado' => { isa => 'Danger' },

sub dangerous : throws(Danger'Avalanche,Danger'Tornado) { }

If 'dangerous' is called from somewhere else and Danger::Avalanche and
Danger::Tornado (or any ancestor exception class, i. e. Danger or
Exception::Class) are not being caught,
then an exception like <<'__THIS__' will be thrown:
Exceptions 'Danger::Avalanche', 'Danger::Tornado' are not being caught
at line 8

I've got a couple of questions:
1. Is there something like this already available?
2. What name for 'TheModule' can you suggest?
3. Any ideas how to make 'exception not being caught' exception be
thrown during the compilation phase, to make sure all thrown
exceptions are caught in the code, even if some subroutines are not
called afterwards during the execution? In other words, do you see a
way how to get the stack of subroutine calls during the compilation
phase, not waiting for subroutines are really executed?


Site Timeline