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       By default, this policy allows uses of "die" and "warn" ending in an
43       explicit newline. If you give this policy an
44       "allow_messages_ending_with_newlines" option in your .perlcriticrc with
45       a false value, then this policy will prohibit such uses.
46
47           [ErrorHandling::RequireCarping]
48           allow_messages_ending_with_newlines = 0
49
50       If you give this policy an "allow_in_main_unless_in_subroutine" option
51       in your .perlcriticrc with a true value, then this policy will allow
52       "die" and "warn" in name space main:: unless they appear in a
53       subroutine, even if they do not end in an explicit newline.
54
55           [ErrorHandling::RequireCarping]
56           allow_in_main_unless_in_subroutine = 1
57

BUGS

59       Should allow "die" when it is obvious that the "message" is a
60       reference.
61

SEE ALSO

63       Carp::Always
64

AUTHOR

66       Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
67
69       Copyright (c) 2005-2011 Imaginative Software Systems.  All rights
70       reserved.
71
72       This program is free software; you can redistribute it and/or modify it
73       under the same terms as Perl itself.  The full text of this license can
74       be found in the LICENSE file included with this module.
75
76
77
78perl v5.32.0            Perl::Crit2i0c2:0:-P0o7l-i2c8y::ErrorHandling::RequireCarping(3)
Impressum