Questions tagged [carp]

Carp is intended for questions regarding either the word Carp - a Perl module to return module-oriented stack traces, warnings and errors, or one of the following acronyms: Cache Array Routing Protocol (CARP) - a distributed caching algorithm used in load-balancing HTTP requests; or Common Address Redundancy Protocol (CARP) - a distributed networking algorithm for sharing IP addresses.

References

24 questions
61
votes
2 answers

What's the difference between Carp/Croak, Cluck/Confess, and verbose options?

I haven't used Carp all that much because I've generally rolled my own. However, in the spirit of keeping with Core modules, I'm using it now. However, it seems like it's barely better than warn/die. Furthermore, what does cluck/confess/verbose…
SineSwiper
  • 2,046
  • 2
  • 18
  • 22
26
votes
4 answers

Why should I use Carp instead of warn in Perl?

People keep giving me examples with carp instead of warn. Why? What makes carp better than warn?
Frew Schmidt
  • 9,364
  • 16
  • 64
  • 86
18
votes
4 answers

How can I replace all 'die's with 'confess' in a Perl application?

I'm working in a large Perl application and would like to get stack traces every time 'die' is called. I'm aware of the Carp module, but I would prefer not to search/replace every instance of 'die' with 'confess'. In addition, I would like full…
Mike Ottum
  • 1,361
  • 1
  • 12
  • 20
9
votes
2 answers

What's the raku analog of perl 5's carp?

By default, Raku's "die" reports the line number where the "die" is located, what if you'd like the line number of the calling context, ala "carp" with perl 5?
Joseph Brenner
  • 664
  • 3
  • 14
7
votes
4 answers

Is there a C equivalent for Perl's Carp module?

In some projects I've done in C, I've liked using the following macros which work similar to Perl's warn and die subroutines: #include #include #define warn(...) \ fprintf(stderr, __VA_ARGS__); \ fprintf(stderr, " at %s…
Jake
  • 111
  • 3
6
votes
1 answer

How do you catch a buggy sig die handler if the mechanism to debug code that everyone uses overrides it?

Let's say you use a cpan (or otherwise external) module, like our fictional one here Stupid::CPAN::Module::OfSatan package Stupid::CPAN::Module::OfSatan { BEGIN { $SIG{__DIE__} = sub { print STDERR "ERROR"; exit; }; } } Now later in your code you…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
6
votes
2 answers

How can I mark a call as "unsafe" with Carp?

I have the same problem as in Can't disable stack trace in Carp::croak() for some reason. Because every call in the stack is considered "safe", croak() prints out a full stack trace every time. I'd like to disable that for certain calls. Here's an…
Jonathan
  • 1,163
  • 7
  • 12
4
votes
2 answers

Infinite loop in perl Carp module

We have some code which catches an exception, logs the message and then calls Carp::longmess to get the stacktrace. So a simplified view of what we are doing is: eval { }; if( my $err = $@ ) { logwrite( "Caught Error:…
Sodved
  • 8,428
  • 2
  • 31
  • 43
4
votes
1 answer

croaking from a Moose BUILD method

I want my class to blow up if the BUILD method fails. However, if I use croak to handle the error, the error gets reported from Class/MOP/Method.pm, rather than the caller's code. (That is to say, the caller who instantiates the object.) IOW, croak…
friedo
  • 65,762
  • 16
  • 114
  • 184
4
votes
3 answers

Why won't prove accept -MCarp=verbose?

I ran this test script: use strict; use warnings; use Test::More tests => 3; use Carp; ok(1<2); pass(); fail(); croak "example"; using the command line prove -MCarp=verbose -v foo.pl, and got the following errors: Subroutine App::Prove::verbose…
Philip Potter
  • 8,975
  • 2
  • 37
  • 47
3
votes
1 answer

How can I write a SIG{__DIE__} handler that does not trigger in eval blocks?

According to the perldoc -f die, which documents $SIG{__DIE__} Although this feature was to be run only right before your program was to exit, this is not currently so: the $SIG{__DIE__} hook is currently called even inside evaled blocks/strings!…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
3
votes
1 answer

Perl Carp:confess unit test

I am trying to write a perl unit test. I am able to test happy-case scenario for it. However if there is an error generated in the method it prints the error using Carp:confess "". I am not able to catch this case in my test. I tried using…
alwaysAStudent
  • 2,110
  • 4
  • 24
  • 47
2
votes
1 answer

Overriding croak cluck confess carp from carp module in Perl

I know how to override in built functions in perl and I have overridden die warn say and since print and printf can't be overridden I have tied it to a handle for my logging framework. Example of overriding warn: BEGIN{ *CORE::GLOBAL::warn = sub { …
Dinesh Gowda
  • 1,044
  • 3
  • 13
  • 29
2
votes
0 answers

Ucarp update switch's arp cache

I'm using ucarp over linux bonding for high availability and automatic failover of two servers. Here are the commands I used on each server for starting ucarp : Server 1 : ucarp -i bond0 -v 2 -p secret -a 10.110.0.243 -s 10.110.0.229…
MythTitans
  • 63
  • 5
2
votes
0 answers

Perl / Apache / CGI / Carp : Cannot get fatalsToBrowser to work

I am writing a perl web application running with apache and want to redirect error messages to the browser for debugging. For this, I found fatalsToBrowser from CGI::Carp. Unfortunately, I still get an 'Internal Server Error' instead of the error…
user1981275
  • 13,002
  • 8
  • 72
  • 101
1
2