Exception-Class - Exception::Class objects in scalar context

Posted on Tue Dec 27 19:57:04 2005 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