make github the primary repository
[gitmo/Moose.git] / lib / Moose / Error / Util.pm
CommitLineData
8748a8e8 1package # pretend this doesn't exist, because it shouldn't
2 Moose::Error::Util;
3
4use strict;
5use warnings;
6
7# this intentionally exists to have a place to put this logic that doesn't
8# involve loading Class::MOP, so... don't do that
9
10use Carp::Heavy;
11
12sub _create_error_carpmess {
13 my %args = @_;
14
15 my $carp_level = 3 + ( $args{depth} || 0 );
16 local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though
17
18 my @args = exists $args{message} ? $args{message} : ();
19
20 if ( $args{longmess} || $Carp::Verbose ) {
21 local $Carp::CarpLevel = ( $Carp::CarpLevel || 0 ) + $carp_level;
22 return Carp::longmess(@args);
23 } else {
24 return Carp::ret_summary($carp_level, @args);
25 }
26}
27
28sub create_error_croak {
29 _create_error_carpmess(@_);
30}
31
32sub create_error_confess {
33 _create_error_carpmess(@_, longmess => 1);
34}
35
36sub create_error {
37 if (defined $ENV{MOOSE_ERROR_STYLE} && $ENV{MOOSE_ERROR_STYLE} eq 'croak') {
38 create_error_croak(@_);
39 }
40 else {
41 create_error_confess(@_);
42 }
43}
44
451;
3900cea1 46
47__END__
48
49=pod
50
51=for pod_coverage_needs_some_pod
52
53=cut
54