Skip to content

Commit

Permalink
Item12180: Improve error reporting
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@16300 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
TimotheLitt authored and TimotheLitt committed Dec 30, 2012
1 parent 802239d commit 7a98c35
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 49 deletions.
44 changes: 28 additions & 16 deletions core/lib/Foswiki/Configure/Checkers/ExtensionsRepositories.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,22 @@ sub check {

my @list = @{ $h{repositories} } if ( $h{repositories} );

if ( ( my $err = $h{_repositoryerror} ) ) {
return $this->ERROR( "Syntax error in repository list<br>"
. substr( $v, 0, length($v) - length($err) )
. '<<= near HERE '
. $err );
}
return $this->ERROR("Syntax error in repository list")
unless ( @list && $h{_repositoryerror} && $h{_repositoryerror} eq ';' );
unless (@list);

my $newval = '';

my $table .=
'<table class="foswikiSmall"><thead><tr><td>Name<td>Data URL<td>Pub URL<td colspan="2">Authentication<tbody>';
%h = ();
my $table .= '<table class="foswikiSmall"><thead>
<tr><td>Name<td>Data URL<td>Pub URL<td colspan="2">Authentication
<tbody>';

%h = ();
my $r = 0;

foreach my $repo (@list) {
Expand All @@ -69,7 +76,10 @@ sub check {
},
);
if ($msg) {
$e .= $this->ERROR( "in $repo->{name}:" . $msg );
$e .=
$this->ERROR( "in entry $r"
. ( $repo->{name} ? " ($repo->{name})" : '' )
. ":$msg" );
}

( $repo->{data}, $repo->{pub} ) =
Expand All @@ -78,6 +88,7 @@ sub check {
$newval .= ';' if ($newval);

my $txt = $repo->{name} || '';
$h{ids}{$r} = $txt;
$newval .= $txt . '=(';
$table .= "<tr><td>$txt";
if ($txt) {
Expand All @@ -95,25 +106,27 @@ sub check {
$table .= "<td>$txt";
if ($txt) {
$n .= $this->WARN(
"Duplicated repository data URL: $txt at entry $r, also used for entry $h{data}{$txt}"
"Duplicated repository data URL: $txt at entry $r ($h{ids}{$r}), also used for entry $h{data}{$txt} ($h{ids}{$h{data}{$txt}})"
) if ( $h{data}{$txt} );
$h{data}{$txt} = $r;
}
else {
$e .= $this->ERROR("No data URL specified for repository entry $r");
$e .= $this->ERROR(
"No data URL specified for repository entry $r ($h{ids}{$r})");
}

$txt = $repo->{pub} || '';
$newval .= ",$txt";
$table .= "<td>$txt";
if ($txt) {
$n .= $this->WARN(
"Duplicated repository pub URL: $txt at entry $r, also used for entry $h{pub}{$txt}"
"Duplicated repository pub URL: $txt at entry $r ($h{ids}{$r}), also used for entry $h{pub}{$txt} ($h{ids}{$h{pub}{$txt}})"
) if ( $h{pub}{$txt} );
$h{pub}{$txt} = $r;
}
else {
$e .= $this->ERROR("No pub URL specified for repository entry $r");
$e .= $this->ERROR(
"No pub URL specified for repository entry $r ($h{ids}{$r})");
}

if ( defined $repo->{user} ) {
Expand All @@ -140,13 +153,12 @@ sub check {
}
else {
$n .= $this->NOTE(
"Repository list"
. (
@list
? " <span class='foswikiSmallish'>(Each extension installs from the <b>last</b> repository listed that contains it.)</span>"
: ''
)
. $table
(
@list > 1
? "Repositories <span class='foswikiSmallish'>(Each extension installs from the <b>last</b> repository listed that contains it.)</span>"
: 'Repository'
)
. $table
);
if ( $newval eq $value ) {
$this->setItemValue( $value, $keys );
Expand Down
78 changes: 45 additions & 33 deletions core/lib/Foswiki/Configure/UI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,37 @@ sub reset {
Build descriptive hashes for the repositories listed in
$Foswiki::cfg{ExtensionsRepositories}
name=(dataUrl,pubURL[,user,password]) ; ...
=cut

sub findRepositories {
my $this = shift;
unless ( defined( $this->{repositories} ) ) {
my $replist = '';
$replist .= $Foswiki::cfg{ExtensionsRepositories}
$replist = $Foswiki::cfg{ExtensionsRepositories}
if defined $Foswiki::cfg{ExtensionsRepositories};
$replist = ";$replist;";
while (
$replist =~ s/[;\s]+(.*?)=\((.*?),(.*?)(?:,(.*?),(.*?))?\)\s*;/;/ )
{
push(
@{ $this->{repositories} },
{ name => $1, data => $2, pub => $3, user => $4, pass => $5 }
);

while ( $replist =~ s/^\s*([^=;]+)=\(([^)]*)\)// ) {
my ( $name, $value ) = ( $1, $2 );
if ( $value =~
/^([a-z]+:[^,]+),\s*([a-z]+:[^,]+)(?:,\s*([^,]*),\s*(.*))?$/ )
{
push @{ $this->{repositories} },
{
name => $name,
data => $1,
pub => $2,
user => $3,
pass => $4
};
}
else {
$this->{_repositoryerror} ||= "$value)$replist";
}
last unless ( $replist =~ s/^\s*;\s*// );
}
$this->{_repositoryerror} =
$replist; # Should end with ';' - save for checker
$this->{_repositoryerror} ||= $replist;
}
}

Expand Down Expand Up @@ -588,6 +600,28 @@ sub FB_MODAL {
=begin TML
---++ ObjectMethod FB_ACTION(...)
Encodes actions to be performed by javascript.
$target = #id or name
$actions =
t = scroll to top
b = scroll to bottom
=cut
sub FB_ACTION {
my $this = shift;
my $target = shift;
my $actions = shift;
my $text = "{$target}$actions\006" . join( '', @_ );
return "\001" . length($text) . ",$text";
}
=begin TML
---++ ObjectMethod extractCheckerText( $output ) => $text
Removes FB_* data from $output, returning just the text.
Expand Down Expand Up @@ -643,28 +677,6 @@ sub extractCheckerText {
=begin TML
---++ ObjectMethod FB_ACTION(...)
Encodes actions to be performed by javascript.
$target = #id or name
$actions =
t = scroll to top
b = scroll to bottom
=cut
sub FB_ACTION {
my $this = shift;
my $target = shift;
my $actions = shift;
my $text = "{$target}$actions\006" . join( '', @_ );
return "\001" . length($text) . ",$text";
}
=begin TML
---++ ObjectMethod hidden($value) -> $html
Used in place of CGI::hidden, which is broken in some CGI versions.
HTML encodes the value
Expand Down

0 comments on commit 7a98c35

Please sign in to comment.