Perl: Carp::Always not working in Catalyst MyApp.pm

人走茶凉 提交于 2019-12-24 20:55:53

问题


Related to the topic Perl: Force stacktrace for "can't call method on undefined" I have the following followup question:

I'm using Perl and Catalyst as Web-Framework and I want to get a stacktrace for ANY exception (for some there are already stacktraces but not for all, see linked question).

As suggested in the linked question, the solution is to insert use Carp::Always; "somehwere in the code".

Inserting use Carp::Always; in the Catalyst main package file MyApp.pm (where all the initialization is located) or in any other .pm file has no effect.

But putting it into the scripts/myapp_server.pl prints the desired stacktrace if an exception occurs.

Why do I have to put use Carp::Always; into the myapp_sever.pl file and why isn't it working if I put it into MyApp.pm?

Putting it into _server.pl is not the best solution because then I have to define it additionally in the mod_perl config (PerlModule Carp::Always) when using apache to deliver the page.

EDIT: I also tried with a freshly created Catalyst app:

  1. Create a new app: catalyst.pl ExTest
  2. Add use Carp::Always; to lib/ExTest.pm (very first line)
  3. Add the example sub test ... from Perl: Force stacktrace for "can't call method on undefined" to lib/Controller/Root.pm right before 1; (last line)
  4. Call perl Makefile.PL && make
  5. Start the server perl scripts/extest_server.pl
  6. Open http://localhost:3000/test

    The full stacktrace is missing...

Now try the following:

  1. Remove previously added use Carp::Always
  2. Add use Carp::Always; to script/extest_server.pl (second line)
  3. Open http://localhost:3000/test

    Now there is a full stacktrace

My Catalyst version is: 5.90041

Perl Version: 5.10.1 (I know it's old but there are no official releases for Ubuntu 10.04 Server)

May it be related to the Perl version?

来源:https://stackoverflow.com/questions/17661617/perl-carpalways-not-working-in-catalyst-myapp-pm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!