Perl equivalent to Java's "throws" clausule.

Posted by Konerak on Stack Overflow See other posts from Stack Overflow or by Konerak
Published on 2010-04-28T07:11:02Z Indexed on 2010/04/28 7:13 UTC
Read the original article Hit count: 463

Filed under:
|
|
|
|

Is there a way in Perl to declare that a method can throw an error (or die)?

I always loved how in Java, a method could handle an Exception and/or throw it. The method signature allows to put "throws MyException", so a good IDE/compiler would know that if you use said method somewhere in your code, you'd have to check for the Exception or declare your function to "throws" the Exception further.

I'm unable to find something alike in Perl. A collegue of mine wrote a method which "dies" on incorrect input, but I forget to eval-if($@) it... offcourse the error was only discovered while a user was running the application.

(offcourse I doubt if there is any existing IDE that could find these kind of things for Perl, but atleast perl -cw should be able to, no?)

© Stack Overflow or respective owner

Related posts about perl

Related posts about exception