I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2005-12-27 17:57:04-08 by earl
Exception::Class objects in scalar context
I am using Exception::Class and I wanted some clarification. I created a simple exception class like ...
use Exception::Class ( 'MyException', ... };
In scalar context, an Exception::Class object implicitly invokes as_string, which invokes message. If the "throw" call doesn't specify a message, the message method returns $!.

Why was $! chosen as the default, over something like "Generic Exception"? When my program did not catch MyException properly, it printed some unrelated error messages. Also, the results were sometimes non-deterministic. This made it harder to find the original problem. Since I throw MyException explicitly under normal conditions, the value of $! is not an appropriate message for MyException.

Thanks!

Direct Responses: 1541 | Write a response