Ask a Question related to PERL Modules, Design and Development.
-
Peter Scott #1
Re: Error.pm -- trying to catch multiple exceptions
In article <g261ivc6640q7u116t0cg7fts0mfkv8fmk@4ax.com>,
ed <coo_t2-NO-LIKE-SPAM@yahoo.com> writes:That's the way it's supposed to work. An exception is an immediate non-local>Hey all. I'm experiment with Error.pm .
>It's the module that lets you use Try/Catch blocks to handle
>exceptions.
>
>I was wondering, shouldn't both exceptions below be caught?
>When I run it, it only catches the first one.
>
>It catches either exception, if I only throw one exception at a time.
>But it _only_ catches one.
>In other words if I comment out the first line that throws an
>exception
>in the try block below, the second one will be thrown and caught.
>So only the first exception is being caught.
>
>Am I using it right or is this the way it's suppose to work?
transfer of control. For 'throw' read 'die'. You can only die once, unless
you're a cat or James Bond, right?
[snip]>try {
> throw Exception('Exception');
> throw IOException('IOException');
>}
--
Peter Scott
[url]http://www.perldebugged.com[/url]
Peter Scott Guest
-
global catch error?
Hi, is it possible to catch ALL uncatched errors of my application? I want to have the possibility to show my own error dialog for all errors... -
catch loadMovie error?
Howdy, it's a "newbie to Flash" question.. sorry! I am using the loadMovie() action but need to be able to catch errors e.g. If the jpg/swf I... -
catch 401.2 error
Dear collegues! I am trying to create a single Login Application, that can either authenticate against a database or against ADSI. Intenal users... -
catch an 401.2 error
Dear collegues! I am trying to create a single Login Application, that can either authenticate against a database or against ADSI. Intenal users... -
Catch Exceptions for Asyncronous Invoke
How can I catch exceptions of web service, when I am using Asyncronouse Invoke (like: myService.BeginGetCustomers()) I want to catch exceptions... -
Peter Pentchev #2
Re: Error.pm -- trying to catch multiple exceptions
ed <coo_t2-NO-LIKE-SPAM@yahoo.com> wrote in message news:<g261ivc6640q7u116t0cg7fts0mfkv8fmk@4ax.com>. ..
[snip]> Hey all. I'm experiment with Error.pm .
> It's the module that lets you use Try/Catch blocks to handle
> exceptions.
>
> I was wondering, shouldn't both exceptions below be caught?
> When I run it, it only catches the first one.
>
> It catches either exception, if I only throw one exception at a time.
> But it _only_ catches one.
> In other words if I comment out the first line that throws an
> exception
> in the try block below, the second one will be thrown and caught.
> So only the first exception is being caught.
>
> Am I using it right or is this the way it's suppose to work?This is the way it's supposed to work. When something throws an> try {
> throw Exception('Exception');
> throw IOException('IOException');
> }
> catch Exception with {
> my $e = shift;
> print Dumper($e);
> }
> catch IOException with {
> my $e = shift;
> print Dumper($e);
> };
exception, the program execution is stopped. If there is no handler
for this particular exception, Perl will display an error message and
the whole program will terminate. If there is a handler, then Perl
will execute the instructions in the handler and then continue with
the code *immediately after* the whole try..catch block (well, it will
execute the instructions in the finally clause, if there is one).
Thus, when you throw the first exception, no matter whether there is
an exception handler that will catch it or not, the instructions from
the 'throw' to the end of the 'try' clause will most certainly *not*
be executed. This is the way exceptions behave in all languages that
have them (and that I am familiar with; maybe I should put 'most' there
instead of 'all'): whenever an exception is thrown, none of the code
after it in the 'try' clause is executed, because an exception signals
an, well, exceptional condition - usually some grave problem/error -
meaning that some operations were not completed and the code that would
try to use their results would fail in strange and unpredictable ways.
G'luck,
Peter
Peter Pentchev Guest
-
ed #3
Re: Error.pm -- trying to catch multiple exceptions
On 25 Jul 2003 06:54:38 -0700, [email]roam@ringlet.net[/email] (Peter Pentchev)
wrote:
Ok, I wasn't sure about that. The language I'm most comfortable with>
>This is the way it's supposed to work.
is PHP, and it doesn't support try/catch, although PHP 5 will. I
think I heard that Perl 6 will have them built in too. ?
I'm trying to get more comfortable with OO-ish way of doing things
since even the two most popular scripting languages(Perl && PHP) seem
to be moving more towards it. That and I'd also like to one day be
comfortable with Java, Python, and C++, which all use try/catch..
However I've been reading a C++ book lately and it gives me a headache
every time I pick it up :)
Thanks all.
--ed
ed Guest



Reply With Quote

