Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Forgetfulness and 6-months-from-now-you

by hippo (Canon)
on Jan 12, 2018 at 11:29 UTC ( #1207150=note: print w/replies, xml ) Need Help??

in reply to Forgetfulness and 6-months-from-now-you

Now don't take this the wrong way, but did you know that you can set RaiseError and PrintError when you initiate the connection? That way you don't need to check for (and die on) errors every time because DBI will do it for you. It might just save you a lot of typing.

  • Comment on Re: Forgetfulness and 6-months-from-now-you

Replies are listed 'Best First'.
Re^2: Forgetfulness and 6-months-from-now-you
by oakbox (Chaplain) on Jan 15, 2018 at 11:04 UTC

    I don't take it the wrong way :)

    Most of my work is generating content for an API, which wants specifically formatted error handling (which I conveniently left out of my post). I want to die in a clean, and parse-able, way so that the programmer on the other end can either a) figure out what they did wrong or b) communicate with me effectively about what happened. I also use a lot of Mark Overmeer's excellent Log::Report module to make sane logs for internal analysis.

    I COULD override die, I guess, and generate something that way. But my laziness doesn't extend that far.

      I COULD override die, I guess, and generate something that way. But my laziness doesn't extend that far.

      I would probably be that lazy:

      my $dbh=DBI->connect(..., {RaiseError => 1}); # later: if (eval { # use $dbh # perhaps the entire API handling 1; }) { # report success to the API } else { my $error=$@; # Post-Process $error if needed # report $error to the API }


      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1207150]
and the questions are moot...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2018-07-23 14:11 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (469 votes). Check out past polls.