[pastebot-cvs] pastebot/Util Conf.pm,1.11,1.12
Status: Beta
Brought to you by:
rcaputo
|
From: <rc...@us...> - 2004-11-01 16:08:56
|
Update of /cvsroot/pastebot/pastebot/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21117/Util Modified Files: Conf.pm Log Message: Improve error messages, especially ones surrounding bad configuration files. Index: Conf.pm =================================================================== RCS file: /cvsroot/pastebot/pastebot/Util/Conf.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Conf.pm 9 Sep 2004 03:12:53 -0000 1.11 --- Conf.pm 1 Nov 2004 16:08:42 -0000 1.12 *************** *** 61,64 **** --- 61,66 ---- sub flush_section { + my $cfile = shift; + if (defined $section) { *************** *** 68,72 **** if ($item_type & REQUIRED) { die( ! "section `$section' ", "requires item `$item_name' ", "at $cfile line $section_line\n" --- 70,74 ---- if ($item_type & REQUIRED) { die( ! "conf error: section `$section' ", "requires item `$item_name' ", "at $cfile line $section_line\n" *************** *** 76,81 **** die( ! "section `$section' ", ! "item `$item{name}' is redefined at $section_line\n" ) if exists $config{$item{name}}; --- 78,83 ---- die( ! "conf error: section `$section' ", ! "item `$item{name}' is redefined at $cfile line $section_line\n" ) if exists $config{$item{name}}; *************** *** 103,110 **** unless ( $cfile and -f $cfile ) { ! die "\n$0: Cannot read configuration file [$cfile], tried: @conf"; } ! open(MPH, "<$cfile") or die "config file [$cfile] $!"; while (<MPH>) { chomp; --- 105,114 ---- unless ( $cfile and -f $cfile ) { ! die "\nconf error: Cannot read configuration file [$cfile], tried: @conf"; } ! open(MPH, "<$cfile") or ! die "\nconf error: Cannot open configuration file [$cfile]: $!"; ! while (<MPH>) { chomp; *************** *** 116,125 **** die( ! "cannot use an indented item ($1) outside of an unindented section ", "at $cfile line $.\n" ) unless defined $section; die( ! "item `$item' does not belong in section `$section' ", "at $cfile line $.\n" ) unless exists $define{$section}->{$1}; --- 120,130 ---- die( ! "conf error: ", ! "can't use an indented item ($1) outside of an unindented section ", "at $cfile line $.\n" ) unless defined $section; die( ! "conf error: item `$1' does not belong in section `$section' ", "at $cfile line $.\n" ) unless exists $define{$section}->{$1}; *************** *** 130,134 **** } else { ! die "option $1 redefined at $cfile line $.\n"; } } --- 135,139 ---- } else { ! die "conf error: option $1 redefined at $cfile line $.\n"; } } *************** *** 148,152 **** # A new section ends the previous one. ! &flush_section(); $section = $1; --- 153,157 ---- # A new section ends the previous one. ! flush_section($cfile); $section = $1; *************** *** 164,171 **** } ! die "syntax error in $cfile at line $.\n"; } ! &flush_section(); close MPH; --- 169,176 ---- } ! die "conf error: syntax error in $cfile at line $.\n"; } ! flush_section($cfile); close MPH; |