Skip to content

Commit 5003f94

Browse files
committed
pgindent: improve error messages
per suggestion from Gurjeet Singh
1 parent 8daa4e9 commit 5003f94

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/tools/pgindent/pgindent

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ my %options = (
3030
"excludes=s" => \$excludes,
3131
"indent=s" => \$indent,
3232
"build" => \$build,);
33-
GetOptions(%options) || die "bad command line";
33+
GetOptions(%options) || die "bad command line argument";
3434

3535
run_build($code_base) if ($build);
3636

@@ -118,10 +118,11 @@ sub load_typedefs
118118
if (-f "$tdtry/src/tools/pgindent/typedefs.list");
119119
$tdtry = "$tdtry/..";
120120
}
121-
die "no typedefs file" unless $typedefs_file && -f $typedefs_file;
121+
die "cannot locate typedefs file \"$typedefs_file\""
122+
unless $typedefs_file && -f $typedefs_file;
122123

123124
open(my $typedefs_fh, '<', $typedefs_file)
124-
|| die "opening $typedefs_file: $!";
125+
|| die "cannot open typedefs file \"$typedefs_file\": $!";
125126
my @typedefs = <$typedefs_fh>;
126127
close($typedefs_fh);
127128

@@ -143,7 +144,7 @@ sub process_exclude
143144
{
144145
if ($excludes && @files)
145146
{
146-
open(my $eh, '<', $excludes) || die "opening $excludes";
147+
open(my $eh, '<', $excludes) || die "cannot open exclude file \"$excludes\"";
147148
while (my $line = <$eh>)
148149
{
149150
chomp $line;
@@ -162,7 +163,7 @@ sub read_source
162163
my $source;
163164

164165
open(my $src_fd, '<', $source_filename)
165-
|| die "opening $source_filename: $!";
166+
|| die "cannot open file \"$source_filename\": $!";
166167
local ($/) = undef;
167168
$source = <$src_fd>;
168169
close($src_fd);
@@ -177,7 +178,7 @@ sub write_source
177178
my $source_filename = shift;
178179

179180
open(my $src_fh, '>', $source_filename)
180-
|| die "opening $source_filename: $!";
181+
|| die "cannot open file \"$source_filename\": $!";
181182
print $src_fh $source;
182183
close($src_fh);
183184
}
@@ -436,25 +437,25 @@ sub run_build
436437
$code_base = "$code_base/..";
437438
}
438439

439-
die "no src/tools/pgindent directory in $code_base"
440+
die "cannot locate src/tools/pgindent directory in \"$code_base\""
440441
unless -d "$code_base/src/tools/pgindent";
441442

442443
chdir "$code_base/src/tools/pgindent";
443444

444-
my $rv = getstore("http://buildfarm.postgresql.org/cgi-bin/typedefs.pl",
445-
"tmp_typedefs.list");
445+
my $typedefs_list_url = "http://buildfarm.postgresql.org/cgi-bin/typedefs.pl";
446446

447-
die "fetching typedefs.list" unless is_success($rv);
447+
my $rv = getstore($typedefs_list_url, "tmp_typedefs.list");
448+
449+
die "cannot fetch typedefs list from $typedefs_list_url" unless is_success($rv);
448450

449451
$ENV{PGTYPEDEFS} = abs_path('tmp_typedefs.list');
450452

451-
my $pg_bsd_indent_name = "pg_bsd_indent-" . $INDENT_VERSION . ".tar.gz";
453+
my $pg_bsd_indent_url = "ftp://ftp.postgresql.org/pub/dev/pg_bsd_indent-" .
454+
$INDENT_VERSION . ".tar.gz";
452455

453-
$rv =
454-
getstore("ftp://ftp.postgresql.org/pub/dev/$pg_bsd_indent_name",
455-
"pg_bsd_indent.tgz");
456+
$rv = getstore($pg_bsd_indent_url, "pg_bsd_indent.tgz");
456457

457-
die "fetching $pg_bsd_indent_name" unless is_success($rv);
458+
die "cannot fetch BSD indent tarfile from $pg_bsd_indent_url" unless is_success($rv);
458459

459460
# XXX add error checking here
460461

@@ -484,7 +485,7 @@ sub build_clean
484485
$code_base = "$code_base/..";
485486
}
486487

487-
die "no src/tools/pgindent directory in $code_base"
488+
die "cannot locate src/tools/pgindent directory in \"$code_base\""
488489
unless -d "$code_base/src/tools/pgindent";
489490

490491
chdir "$code_base";

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy