in reply to Re: Tl::MainLoop() catch errors
in thread Tl::MainLoop() catch errors

Thanks!

I have a followup question...it seems I need to call die() to get the eval{} to catch the error...maybe it is DBI specific though...I guess I don't understand who is "raising" the error to eval {} me or some library code??? ($@ doesn't catch an error unless I call die() eventhough the library is printing error messages...)

eval { my $dbh = DBI->connect("bad stuff here")...|| die "dead"; } if($@) { print "ERROR" }

Replies are listed 'Best First'.
Re: Re: Re: Tl::MainLoop() catch errors
by rjray (Chaplain) on Feb 20, 2002 at 05:40 UTC

    Well, if the call to DBI->connect() doesn't cause a fatal error, can't you just examine the value of $dbh to see if there was an internal error that was by nature non-fatal? Of course, you probably don't want to be declaring $dbh to be a lexical within the scope of the eval {}... I would think you want the handle if the connect succeeds.

    --rjray

Re: Re: Re: Tl::MainLoop() catch errors
by rinceWind (Monsignor) on Feb 20, 2002 at 11:14 UTC

    If you set $DBI::RaiseError to 1, the exceptions are raised for you (i.e. DBI calls die).