From 7a98c3581352f6be5511f197c6a93a42b1f23298 Mon Sep 17 00:00:00 2001 From: TimotheLitt Date: Sun, 30 Dec 2012 03:43:58 +0000 Subject: [PATCH] Item12180: Improve error reporting git-svn-id: http://svn.foswiki.org/trunk@16300 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- .../Checkers/ExtensionsRepositories.pm | 44 +++++++---- core/lib/Foswiki/Configure/UI.pm | 78 +++++++++++-------- 2 files changed, 73 insertions(+), 49 deletions(-) diff --git a/core/lib/Foswiki/Configure/Checkers/ExtensionsRepositories.pm b/core/lib/Foswiki/Configure/Checkers/ExtensionsRepositories.pm index 231aff143f..ef2fcd890b 100644 --- a/core/lib/Foswiki/Configure/Checkers/ExtensionsRepositories.pm +++ b/core/lib/Foswiki/Configure/Checkers/ExtensionsRepositories.pm @@ -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
" + . 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 .= -''; - %h = (); + my $table .= '
NameData URLPub URLAuthentication
+ '; + %h = (); my $r = 0; foreach my $repo (@list) { @@ -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} ) = @@ -78,6 +88,7 @@ sub check { $newval .= ';' if ($newval); my $txt = $repo->{name} || ''; + $h{ids}{$r} = $txt; $newval .= $txt . '=('; $table .= "
NameData URLPub URLAuthentication +
$txt"; if ($txt) { @@ -95,12 +106,13 @@ sub check { $table .= "$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} || ''; @@ -108,12 +120,13 @@ sub check { $table .= "$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} ) { @@ -140,13 +153,12 @@ sub check { } else { $n .= $this->NOTE( - "Repository list" - . ( - @list - ? " (Each extension installs from the last repository listed that contains it.)" - : '' - ) - . $table + ( + @list > 1 + ? "Repositories (Each extension installs from the last repository listed that contains it.)" + : 'Repository' + ) + . $table ); if ( $newval eq $value ) { $this->setItemValue( $value, $keys ); diff --git a/core/lib/Foswiki/Configure/UI.pm b/core/lib/Foswiki/Configure/UI.pm index ee543dd1be..fde9c699f8 100755 --- a/core/lib/Foswiki/Configure/UI.pm +++ b/core/lib/Foswiki/Configure/UI.pm @@ -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; } } @@ -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. @@ -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