Is there a way in Perl to declare that a method may cause an error (or die)?
The EDIT: . What interests me the most is this way of getting the compiler or IDE to tell me that I have an exception to my code.
I always liked how, in Java, a method can handle an exception and / or throw it. The signature of the method allows you to place a "throws MyException", so a good IDE / compiler would know that if you use the specified method somewhere in your code, you will need to check the Exception or declare that your function "throws" the Exception further.
I can not find something similar to Perl. My colleague wrote a method that "dies" when it is entered incorrectly, but I forgot eval-if ($ @) that ... in the end, the error was detected only when the application started.
(offcourse I doubt if there is any existing IDE that could find such things for Perl, but at least perl -cw should be able to, no?)
source
share