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

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/Dispatch.pm 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

Comment on CGI:Application "error"
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 ...
Re: CGI:Application "error"
by Anonymous Monk on Nov 16, 2012 at 03:28 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1004040]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-08-02 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (55 votes), past polls