Back to the month index |
Back to the list index
|
Brian Lavender (brian@brie.com)
Sat, 12 Apr 1997 12:16:42 -0700
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
- Next message: Jason Hudgins: "[mSQL] authentication ALMOST working now.."
- Previous message: Denis St-Amand: "[mSQL] B6, it is just perfect!"
Message-Id: <2.2.32.19970412191642.0070cdf4@popd.ix.netcom.com> Date: Sat, 12 Apr 1997 12:16:42 -0700 From: Brian Lavender <brian@brie.com> Subject: Re: [mSQL] msQL Error Handling with PerlIt sounds as if you know the what the eval statement looks like, but here
is how I would apply it in case you are doing something syntactically wrong
you did not notice.
eval {
$sth_insert = $dbh->Query($insert_stmt);
};
## if an error, say so:
chomp $@, print "[error: $@]" if $@;
If you want to catch more than one error then put an eval statement around
each method and replace the chomp, print line with the below line after each
eval
push (@foo_errors,$@);
At the end of your routine
print "Errors recorded were @foo_errors";
Here is a sample of eval code. It should compile ok and run,but it should
kick out of the eval loop when it hits the dog method. That will set $@.
After the eval statement you see I print $@. Of course my program is still
running. If you have more than one place where you want to error trap then
use more than one eval statement. Collect all the errors in the @foo_errors
and report them later
#!/usr/local/bin/perl
eval {
@barney = ("man\n", "ancient\n\n", "time" , "newline\n");
print "I once new an old man\n @barney";
the dog;
};
## if an error, say so:
chomp $@, print "[error: $@]" if $@;
Hope this helps
Brian
----------------
Brian Lavender
Brie Web Publishing
Owner
Napa, CA
(707) 226-8891
Brie Business Directory - Napa Valley http://www.brie.com/bbd
"Sometimes our only obstacle is the one in our minds."
--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com. Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!
- Next message: Jason Hudgins: "[mSQL] authentication ALMOST working now.."
- Previous message: Denis St-Amand: "[mSQL] B6, it is just perfect!"