tools/DBD: Improve error reporting
Better 'duplicate choice' message Output messages to STDERR
This commit is contained in:
@@ -42,14 +42,12 @@ sub popContext {
|
||||
|
||||
sub dieContext {
|
||||
my ($msg) = join "\n\t", @_;
|
||||
print "$msg\n" if $msg;
|
||||
die "Context: ", join(' in ', @context), "\n";
|
||||
die "$msg\nContext: ", join(' in ', @context), "\n";
|
||||
}
|
||||
|
||||
sub warnContext {
|
||||
my ($msg) = join "\n\t", @_;
|
||||
print "$msg\n" if $msg;
|
||||
print "Context: ", join(' in ', @context), "\n";
|
||||
print STDERR "$msg\nContext: ", join(' in ', @context), "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,8 +15,10 @@ sub add_choice {
|
||||
$name = identifier($name, "Choice name");
|
||||
unquote $value;
|
||||
foreach $pair ($this->choices) {
|
||||
dieContext("Duplicate choice name") if ($pair->[0] eq $name);
|
||||
dieContext("Duplicate choice string") if ($pair->[1] eq $value);
|
||||
dieContext("Duplicate menu choice name '$name'")
|
||||
if ($pair->[0] eq $name);
|
||||
dieContext("Duplicate menu choice string '$value'")
|
||||
if ($pair->[1] eq $value);
|
||||
}
|
||||
push @{$this->{CHOICE_LIST}}, [$name, $value];
|
||||
$this->{CHOICE_INDEX}->{$value} = $name;
|
||||
|
||||
Reference in New Issue
Block a user