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 - Use functions
7       from Carp instead of "warn" or "die".
8

AFFILIATION

10       This Policy is part of the core Perl::Critic distribution.
11

DESCRIPTION

13       The "die" and "warn" functions both report the file and line number
14       where the exception occurred.  But if someone else is using your
15       subroutine, they usually don't care where your code blew up.  Instead,
16       they want to know where their code invoked the subroutine.  The Carp
17       module provides alternative methods that report the exception from the
18       caller's file and line number.
19
20       By default, this policy will not complain about "die" or "warn", if it
21       can determine that the message will always result in a terminal
22       newline.  Since perl suppresses file names and line numbers in this
23       situation, it is assumed that no stack traces are desired either and
24       none of the Carp functions are necessary.
25
26           die "oops" if $explosion;             #not ok
27           warn "Where? Where?!" if $tiger;      #not ok
28
29           open my $mouth, '<', 'food'
30               or die 'of starvation';           #not ok
31
32           if (! $dentist_appointment) {
33               warn "You have bad breath!\n";    #ok
34           }
35
36           die "$clock not set.\n" if $no_time;  #ok
37
38           my $message = "$clock not set.\n";
39           die $message if $no_time;             #not ok, not obvious
40

CONFIGURATION

42       If you give this policy an "allow_messages_ending_with_newlines" option
43       in your .perlcriticrc with a false value, then this policy will
44       disallow all uses of "die" and "warn".
45
46           [ErrorHandling::RequireCarping]
47           allow_messages_ending_with_newlines = 0
48

BUGS

50       This should not complain about using "warn" or "die" if it's not in a
51       function, or if it's in "main::".
52
53       Also, should allow "die" when it is obvious that the "message" is a
54       reference.
55

SEE ALSO

57       Carp::Always
58

AUTHOR

60       Jeffrey Ryan Thalhammer <thaljef@cpan.org>
61
63       Copyright (c) 2005-2009 Jeffrey Ryan Thalhammer.  All rights reserved.
64
65       This program is free software; you can redistribute it and/or modify it
66       under the same terms as Perl itself.  The full text of this license can
67       be found in the LICENSE file included with this module.
68
69
70
71perl v5.10.1            Perl::Crit2i0c1:0:-P1o1l-i1c2y::ErrorHandling::RequireCarping(3)
Impressum