Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

CGI:Application "error"

by neptuneray (Sexton)
on Nov 15, 2012 at 17:02 UTC ( #1004040=perlquestion: print w/replies, xml ) Need Help??
neptuneray has asked for the wisdom of the Perl Monks concerning the following question:

I have a CGI:Application running on Apache/mod_perl. Everything works, except when I get any sort of error. The application terminates with a 500 code, and I get the following message:
"Can't locate object method 'error' via package "Template::Exception" at /usr/local/lib .../CGI/Application/ line 438."

In my Setup sub (where Run Modes are defined), I am setting "$app->error_mode('error')", and then I have my own sub named "error" in that module.

Is it me that is doing something wrong, or is this an internal module error that I have no control over?

Oh, and one more thing ...

In my own error sub, I am trying to use the $app object to call "tt_process" to display my error template.

Possibly I don't have access to the $app object?

In reading the docs, I see that I only get $@ passed.

Does this mean I get to write directly to the client (an otherwise no-no in CGI:Apps)?

Thanks much, Ray

Replies are listed 'Best First'.
Re: CGI:Application "error"
by Anonymous Monk on Nov 16, 2012 at 03:28 UTC
Re: CGI:Application "error"
by neptuneray (Sexton) on Nov 15, 2012 at 17:13 UTC
    and one more thing ...

    In my own error sub, if I print the variable that is passed to me ($@, according to the doc), I get

    "Got error: JCS::Shop=HASH(0x6343538)"

    where "JCS::Shop is the module where this error happens.

    I have NO IDEA of what this is telling me! In the example in the doc, they get a nice clean error message, like "Illegal division by zero", etc.

    Thanks again, Ray

      JCS::Shop=HASH(0xDEADBEEF) and the like happen when you stringify a hash reference blessed into the JCS::Shop package. In this case, you'll probably want to pass $@ to Dumper in Data::Dumper to see what's actually stored in the variable. See Basic debugging checklist.

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

        Thanks for the help. I am now reading a proper Perl error message. But that doesn't mean I'm out of the woods! Looks like I've got some tricky bug lurking somewhere in some module ... oh, well ... sometimes I regret having given up the slide trombone for a career in IT ...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1004040]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2018-06-17 23:09 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.