1Perl::Critic::Policy::EUrsrePorerrHClao:nn:dtClrriiinbtgui:tc:e:Rd:ePqPouelirirlceyCD:ao:rcEpurimrneognr(tH3aa)tnidolning::RequireCarping(3)
2
3
4

NAME

6       Perl::Critic::Policy::ErrorHandling::RequireCarping
7

DESCRIPTION

9       The "die" and "warn" functions both report the file and line number
10       where the exception occurred.  But if someone else is using your sub‐
11       routine, they usually don't care where your code blew up.  Instead,
12       they want to know where their code invoked the subroutine.  The Carp
13       module provides alternative methods that report the exception from the
14       caller's file and line number.
15
16       By default, this policy will not complain about "die" or "warn", if it
17       can determine that the message will always result in a terminal new‐
18       line.  Since perl suppresses file names and line numbers in this situa‐
19       tion, it is assumed that no stack traces are desired either and none of
20       the Carp functions are necessary.
21
22           die "oops" if $explosion;             #not ok
23           warn "Where? Where?!" if $tiger;      #not ok
24
25           open my $mouth, '<', 'food'
26               or die 'of starvation';           #not ok
27
28           if (! $dentist_appointment) {
29               warn "You have bad breath!\n";    #ok
30           }
31
32           die "$clock not set.\n" if $no_time;  #ok
33
34           my $message = "$clock not set.\n";
35           die $message if $no_time;             #not ok, not obvious
36
37       If you give this policy an "allow_messages_ending_with_newlines" option
38       in your .perlcriticrc with a false value, then this policy will disal‐
39       low all uses of "die" and "warn".
40
41           [ErrorHandling::RequireCarping]
42           allow_messages_ending_with_newlines = 0
43

SEE ALSO

45       Carp::Always
46

AUTHOR

48       Jeffrey Ryan Thalhammer <thaljef@cpan.org>
49
51       Copyright (c) 2005-2007 Jeffrey Ryan Thalhammer.  All rights reserved.
52
53       This program is free software; you can redistribute it and/or modify it
54       under the same terms as Perl itself.  The full text of this license can
55       be found in the LICENSE file included with this module.
56
57
58
59perl v5.8.8             Perl::Crit2i0c0:7:-P0o3l-i2c0y::ErrorHandling::RequireCarping(3)
Impressum