good chemistry is complicated,
and a little bit messy -LW
Re^16: eval to replace die?by mithaldu (Monk)
|on Oct 09, 2010 at 11:11 UTC||Need Help??|
re-stating your flawed position over again"=~ is more volatile than eq/ne" is flawed?
I invited corrections, none were forthcoming.Yeah, sorry, i admit i didn't bother to read every single thing before my first post because stuff is very wordy. Here's your problem:
use Exception::Class <stuff_here>; does two things: First, it instantiates all the classes you ask for. In this case MyException being one of them. Optionally you can also ask it to export shortcut subs into the module where you use it. In your case you only ask it to export throw_fields.
To fix your example, change the two "MyExceptions" in sub divide to "MyException", so you're actually trying to throw with the class of an exception (by your use of caught, this is presumably the right option).
And the things you changed mean that you're not using half of the functionality of the module. ... E::C throw() and caught()These are merely convenience functions, clocking in at 15 of 415 code lines (without docs). That is 3.6%. The rest and the majority of the code deals exclusively with the creation of exception objects.
The only reason i did not use them is because i personally do not like them and think T::T looks nicer. Your assumption that i could not get them to work is not correct as my fix to your example above proves.
"Ex->throw" is literally just a shortcut for "die $ex || Ex->new". This has nothing to do with T::T's try, since THAT function does much more stable wrapping of code and does nothing to create exception objects, but only stores them if the wrapped code emits them.
"caught" is only there so you can inspect the errors from the eval and compare them to certain targets in one line. It has only superficial resemblance to try's catch, which is aimed at security and stability and does not have the convenience of actually inspecting the exceptions.
The intent of Exception::Class is merely to provide exception objects, not to provide exception handling. These are two very different domains.
Let's just accept that you think I'm an idiotI don't. At this moment i am of the belief that your hate of another language(*) does not allow you to evaluate things in a complete and rational manner. If i had good memory i would insert a jedi quote here.
(*) And on inspection of your the post with your example, also your hate of one specific person.