@@ -3,30 +3,22 @@ use v5.12.0;
33use warnings;
44
55use Sub::Exporter -setup => {
6- exports => [ ' ERROR ' ],
7- groups => { default => [ ' ERROR ' ] },
6+ exports => [ qw( DISTERROR PKGERROR ) ],
7+ groups => { default => [ qw( DISTERROR PKGERROR ) ] },
88};
99
10- my %ERROR ;
10+ sub dist_error ;
11+ sub pkg_error ;
1112
12- sub public_error {
13- my ($name , $arg ) = @_ ;
14- $ERROR {$name } = {
15- ident => $name ,
16- public => 1,
17- %$arg ,
18- };
19- }
20-
21- public_error blib => {
13+ dist_error blib => {
2214 header => ' archive contains a "blib" directory' ,
2315 body => <<'EOF'
2416The distribution contains a blib/ directory and is therefore not being indexed.
2517Hint: try 'make dist'.
2618EOF
2719};
2820
29- public_error multiroot => {
21+ dist_error multiroot => {
3022 header => ' archive has multiple roots' ,
3123 body => sub {
3224 my ($dist ) = @_ ;
3830 },
3931};
4032
41- public_error no_distname_permission => {
33+ dist_error no_distname_permission => {
4234 header => ' missing permissions on distname package' ,
4335 body => sub {
4436 my ($dist ) = @_ ;
5749 },
5850};
5951
60- public_error no_meta => {
52+ dist_error no_meta => {
6153 header => " no META.yml or META.json found" ,
6254 body => <<'EOF' ,
6355Your archive didn't contain a META.json or META.yml file. You need to include
@@ -66,7 +58,7 @@ ExtUtils::MakeMaker can help with this.
6658EOF
6759};
6860
69- public_error single_pm => {
61+ dist_error single_pm => {
7062 header => ' dist is a single-.pm-file upload' ,
7163 body => <<"EOF" ,
7264You've uploaded a compressed .pm file without a META.json, a build tool, or the
@@ -75,15 +67,15 @@ no longer is. Please use a CPAN distribution building tool.
7567EOF
7668};
7769
78- public_error unstable_release => {
70+ dist_error unstable_release => {
7971 header => ' META release_status is not stable' ,
8072 body => <<'EOF' ,
8173Your META file provides a release status other than "stable", so this
8274distribution will not be indexed.
8375EOF
8476};
8577
86- public_error worldwritable => {
78+ dist_error worldwritable => {
8779 header => ' archive has world writable files' ,
8880 body => sub {
8981 my ($dist ) = @_ ;
9587 },
9688};
9789
98- public_error xact_fail => {
90+ dist_error xact_fail => {
9991 header => " ERROR: Database error occurred during index update" ,
10092 body => <<'EOF' ,
10193This distribution was not indexed due to database errors. You can request
10294another indexing attempt be made by logging into https://pause.perl.org/
10395EOF
10496};
10597
106- sub ERROR {
98+ pkg_error bad_package_name => {
99+ header => ' Not indexed because of invalid package name.' ,
100+ body => <<'EOF' ,
101+ This package wasn't indexed because its name doesn't conform to standard
102+ naming. Basically: one or more valid identifiers, separated by double colons
103+ (::).
104+ EOF
105+ };
106+
107+ pkg_error no_permission => {
108+ header => ' Not indexed because the required permissions were missing.' ,
109+ body => <<'EOF' ,
110+ This package wasn't indexed because you don't have permission to use this
111+ package name. Hint: you can always find the legitimate maintainer(s) on PAUSE
112+ under "View Permissions".
113+ EOF
114+ };
115+
116+ pkg_error version_openerr => {
117+ header => ' Not indexed because of version handling error.' ,
118+ body => <<'EOF' ,
119+ The PAUSE indexer was not able to read the file.
120+ EOF
121+ };
122+
123+ pkg_error version_parse => {
124+ header => ' Not indexed because of version parsing error.' ,
125+ body => <<'EOF' ,
126+ The PAUSE indexer was not able to parse the file.
127+
128+ Note: the indexer is running in a Safe compartement and cannot provide the full
129+ functionality of perl in the VERSION line. It is trying hard, but sometime it
130+ fails. As a workaround, please consider writing a META.yml that contains a
131+ "provides" attribute, or contact the CPAN admins to investigate (yet another)
132+ workaround against "Safe" limitations.
133+ EOF
134+ };
135+
136+ pkg_error version_too_long => {
137+ header => ' Not indexed because the version string was too long.' ,
138+ body => <<'EOF' ,
139+ The maximum length of a version string is 16 bytes, which is already quite
140+ long. Please consider picking a shorter version.
141+ EOF
142+ };
143+
144+ pkg_error wtf => {
145+ header => ' Not indexed: something surprising happened.' ,
146+ body => <<'EOF' ,
147+ The PAUSE indexer couldn't index this package. It ended up with a weird
148+ internal state, like thinking your package name was empty or your version was
149+ undefined. If you see this, you should probably contact the PAUSE admins.
150+ EOF
151+ };
152+
153+ my %DIST_ERROR ;
154+ my %PKG_ERROR ;
155+
156+ sub DISTERROR {
157+ my ($ident ) = @_ ;
158+
159+ my $error = $DIST_ERROR {$ident };
160+ unless ($error ) {
161+ Carp::confess(" requested unknown distribution error: $ident " );
162+ }
163+
164+ return $error ;
165+ }
166+
167+ sub PKGERROR {
107168 my ($ident ) = @_ ;
108169
109- my $error = PAUSE::Indexer::Errors -> error_named( $ ident) ;
170+ my $error = $PKG_ERROR { $ ident} ;
110171 unless ($error ) {
111- Carp::confess(" requested unknown error: $ident " );
172+ Carp::confess(" requested unknown package error: $ident " );
112173 }
113174
114175 return $error ;
115176}
116177
117- sub error_named {
118- my ($self , $ident ) = @_ ;
178+ sub dist_error {
179+ my ($name , $arg ) = @_ ;
180+ $DIST_ERROR {$name } = {
181+ ident => $name ,
182+ public => 1,
183+ %$arg ,
184+ };
185+ }
119186
120- return $ERROR {$ident };
187+ sub pkg_error {
188+ my ($name , $arg ) = @_ ;
189+ $PKG_ERROR {$name } = {
190+ ident => $name ,
191+ public => 1,
192+ %$arg ,
193+ };
121194}
122195
1231961;
0 commit comments