From: dpvc v. a. <we...@ma...> - 2005-07-12 22:33:51
|
Log Message: ----------- A first pass at making parser error messages localizable. The Context()->{error}{msg} hash can be used to specify translations of the standard messages. For example, Context()->{error}{msg}{'Division by zero'} = "Don't divide by zero, dude!"; Context()->{error}{msg}{'Function '%s' has too many inputs'} = "You passed too many arguments to '%s'"; (I didn't translate into another language, here, but you could do that, too.) The msg hash could also be used within answer checkers to make certain answer messages more appropriate for the given type of expected answer. Modified Files: -------------- pg/lib: Parser.pm Value.pm pg/lib/Parser: BOP.pm Context.pm Differentiation.pm Function.pm Item.pm List.pm UOP.pm Value.pm Variable.pm pg/lib/Parser/BOP: equality.pm undefined.pm underscore.pm union.pm pg/lib/Parser/Context: Variables.pm pg/lib/Parser/Function: complex.pm hyperbolic.pm numeric.pm numeric2.pm trig.pm undefined.pm vector.pm pg/lib/Parser/Legacy: LimitedNumeric.pm NumberWithUnits.pm pg/lib/Parser/List: AbsoluteValue.pm pg/lib/Parser/UOP: undefined.pm pg/lib/Value: AnswerChecker.pm Complex.pm Context.pm Formula.pm Infinity.pm Interval.pm Matrix.pm Point.pm Real.pm String.pm Vector.pm pg/lib/Value/Context: Data.pm Revision Data ------------- Index: union.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/BOP/union.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -Llib/Parser/BOP/union.pm -Llib/Parser/BOP/union.pm -u -r1.5 -r1.6 --- lib/Parser/BOP/union.pm +++ lib/Parser/BOP/union.pm @@ -23,7 +23,7 @@ $self->{$op}->typeRef->{name} = $self->{equation}{context}{parens}{interval}{type}; } } - } else {$self->Error("Operands of '$self->{bop}' must be intervals")} + } else {$self->Error("Operands of '%s' must be intervals",$self->{bop})} } Index: undefined.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/BOP/undefined.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -Llib/Parser/BOP/undefined.pm -Llib/Parser/BOP/undefined.pm -u -r1.3 -r1.4 --- lib/Parser/BOP/undefined.pm +++ lib/Parser/BOP/undefined.pm @@ -13,7 +13,7 @@ sub _check { my $self = shift; my $bop = $self->{def}{string} || $self->{bop}; - $self->Error("Can't use '$bop' in this context"); + $self->Error("Can't use '%s' in this context",$bop); } ######################################################################### Index: underscore.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/BOP/underscore.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -Llib/Parser/BOP/underscore.pm -Llib/Parser/BOP/underscore.pm -u -r1.6 -r1.7 --- lib/Parser/BOP/underscore.pm +++ lib/Parser/BOP/underscore.pm @@ -59,7 +59,7 @@ $M,$parser->{Value}->new($equation,@index)) } my $i = shift(@index); $i-- if $i > 0; - $self->Error("Can't extract element number '$i' (index must be an integer)") + $self->Error("Can't extract element number '%s' (index must be an integer)",$i) unless $i =~ m/^-?\d+$/; $M = $M->{coords}[$i]; return $parser->{Value}->new($equation,Value::List->new()) unless $M; Index: equality.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/BOP/equality.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -Llib/Parser/BOP/equality.pm -Llib/Parser/BOP/equality.pm -u -r1.4 -r1.5 --- lib/Parser/BOP/equality.pm +++ lib/Parser/BOP/equality.pm @@ -13,7 +13,7 @@ my $self = shift; my $name = $self->{def}{string} || $self->{bop}; $self->Error("Only one equality is allowed in an equation") if ($self->{lop}->type eq 'Equality' || $self->{rop}->type eq 'Equality'); - $self->Error("Operands of '$name' must be Numbers") unless $self->checkNumbers(); + $self->Error("Operands of '%s' must be Numbers",$name) unless $self->checkNumbers(); $self->{type} = Value::Type('Equality',1); # Make it not a number, to get errors with other operations. } Index: Variables.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context/Variables.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/Parser/Context/Variables.pm -Llib/Parser/Context/Variables.pm -u -r1.7 -r1.8 --- lib/Parser/Context/Variables.pm +++ lib/Parser/Context/Variables.pm @@ -57,7 +57,7 @@ } elsif ($value =~ m/$self->{context}{pattern}{signedNumber}/) { $value = $type{'Real'}; } else { - Value::Error("Unrecognized variable type '$value'"); + Value::Error("Unrecognized variable type '%s'",$value); } return {type => $value, @extra}; } Index: numeric.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Function/numeric.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -Llib/Parser/Function/numeric.pm -Llib/Parser/Function/numeric.pm -u -r1.3 -r1.4 --- lib/Parser/Function/numeric.pm +++ lib/Parser/Function/numeric.pm @@ -26,8 +26,8 @@ # sub _call { my $self = shift; my $name = shift; - Value::Error("Function '$name' has too many inputs") if scalar(@_) > 1; - Value::Error("Function '$name' has too few inputs") if scalar(@_) == 0; + Value::Error("Function '%s' has too many inputs",$name) if scalar(@_) > 1; + Value::Error("Function '%s' has too few inputs",$name) if scalar(@_) == 0; my $n = $_[0]; return $self->$name($n) if Value::matchNumber($n); (Value::Complex::promote($n))->$name; Index: vector.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Function/vector.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -Llib/Parser/Function/vector.pm -Llib/Parser/Function/vector.pm -u -r1.2 -r1.3 --- lib/Parser/Function/vector.pm +++ lib/Parser/Function/vector.pm @@ -28,8 +28,8 @@ # sub _call { my $self = shift; my $name = shift; - Value::Error("Function '$name' has too many inputs") if scalar(@_) > 1; - Value::Error("Function '$name' has too few inputs") if scalar(@_) == 0; + Value::Error("Function '%s' has too many inputs",$name) if scalar(@_) > 1; + Value::Error("Function '%s' has too few inputs",$name) if scalar(@_) == 0; my $v = Value::Vector::promote($_[0]); $v->$name; } Index: trig.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Function/trig.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -Llib/Parser/Function/trig.pm -Llib/Parser/Function/trig.pm -u -r1.2 -r1.3 --- lib/Parser/Function/trig.pm +++ lib/Parser/Function/trig.pm @@ -26,8 +26,8 @@ # sub _call { my $self = shift; my $name = shift; - Value::Error("Function '$name' has too many inputs") if scalar(@_) > 1; - Value::Error("Function '$name' has too few inputs") if scalar(@_) == 0; + Value::Error("Function '%s' has too many inputs",$name) if scalar(@_) > 1; + Value::Error("Function '%s' has too few inputs",$name) if scalar(@_) == 0; my $n = $_[0]; return $self->$name($n) if Value::matchNumber($n); (Value::Complex::promote($n))->$name; Index: hyperbolic.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Function/hyperbolic.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -Llib/Parser/Function/hyperbolic.pm -Llib/Parser/Function/hyperbolic.pm -u -r1.2 -r1.3 --- lib/Parser/Function/hyperbolic.pm +++ lib/Parser/Function/hyperbolic.pm @@ -26,8 +26,8 @@ # sub _call { my $self = shift; my $name = shift; - Value::Error("Function '$name' has too many inputs") if scalar(@_) > 1; - Value::Error("Function '$name' has too few inputs") if scalar(@_) == 0; + Value::Error("Function '%s' has too many inputs",$name) if scalar(@_) > 1; + Value::Error("Function '%s' has too few inputs",$name) if scalar(@_) == 0; my $n = $_[0]; return $self->$name($n) if Value::matchNumber($n); (Value::Complex::promote($n))->$name; Index: undefined.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Function/undefined.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -Llib/Parser/Function/undefined.pm -Llib/Parser/Function/undefined.pm -u -r1.4 -r1.5 --- lib/Parser/Function/undefined.pm +++ lib/Parser/Function/undefined.pm @@ -12,12 +12,12 @@ sub _check { my $self = shift; - $self->Error("Function '$self->{name}' is not allowed in this context"); + $self->Error("Function '%s' is not allowed in this context",$self->{name}); } sub _call { my $self = shift; my $name = shift; - Value::Error("Function '$name' is not allowed in this context"); + Value::Error("Function '%s' is not allowed in this context",$name); } ######################################################################### Index: numeric2.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Function/numeric2.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -Llib/Parser/Function/numeric2.pm -Llib/Parser/Function/numeric2.pm -u -r1.2 -r1.3 --- lib/Parser/Function/numeric2.pm +++ lib/Parser/Function/numeric2.pm @@ -16,7 +16,7 @@ !$self->{params}->[0]->isComplex && !$self->{params}->[1]->isComplex) { $self->{type} = $Value::Type{number}; } else { - $self->Error("Function '$self->{name}' has the wrong type of inputs"); + $self->Error("Function '%s' has the wrong type of inputs",$self->{name}); } } @@ -25,9 +25,9 @@ # sub _call { my $self = shift; my $name = shift; - Value::Error("Function '$name' has too many inputs") if scalar(@_) > 2; - Value::Error("Function '$name' has too few inputs") if scalar(@_) < 2; - Value::Error("Function '$name' has the wrong type of inputs") + Value::Error("Function '%s' has too many inputs",$name) if scalar(@_) > 2; + Value::Error("Function '%s' has too few inputs",$name) if scalar(@_) < 2; + Value::Error("Function '%s' has the wrong type of inputs",$name) unless Value::matchNumber($_[0]) && Value::matchNumber($_[1]); return $self->$name(@_); } Index: complex.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Function/complex.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -Llib/Parser/Function/complex.pm -Llib/Parser/Function/complex.pm -u -r1.3 -r1.4 --- lib/Parser/Function/complex.pm +++ lib/Parser/Function/complex.pm @@ -32,8 +32,8 @@ # sub _call { my $self = shift; my $name = shift; - Value::Error("Function '$name' has too many inputs") if scalar(@_) > 1; - Value::Error("Function '$name' has too few inputs") if scalar(@_) == 0; + Value::Error("Function '%s' has too many inputs",$name) if scalar(@_) > 1; + Value::Error("Function '%s' has too few inputs",$name) if scalar(@_) == 0; my $c = Value::Complex::promote($_[0]); $c->$name; } Index: AbsoluteValue.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/List/AbsoluteValue.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -Llib/Parser/List/AbsoluteValue.pm -Llib/Parser/List/AbsoluteValue.pm -u -r1.3 -r1.4 --- lib/Parser/List/AbsoluteValue.pm +++ lib/Parser/List/AbsoluteValue.pm @@ -16,7 +16,7 @@ $self->Error("Only one value allowed within absolute values") if ($self->{type}{length} != 1); my $arg = $self->{coords}[0]; - $self->Error("Absolute value can't be taken of ".$arg->type) + $self->Error("Absolute value can't be taken of %s",$arg->type) unless ($arg->type =~ /Number|Point|Vector/); $self->{type} = $Value::Type{number}; } Index: undefined.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/UOP/undefined.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -Llib/Parser/UOP/undefined.pm -Llib/Parser/UOP/undefined.pm -u -r1.3 -r1.4 --- lib/Parser/UOP/undefined.pm +++ lib/Parser/UOP/undefined.pm @@ -13,7 +13,7 @@ sub _check { my $self = shift; my $uop = $self->{def}{string} || $self->{uop}; - $self->Error("Can't use '$uop' in this context"); + $self->Error("Can't use '%s' in this context",$uop); } ######################################################################### Index: Real.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Real.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -Llib/Value/Real.pm -Llib/Value/Real.pm -u -r1.16 -r1.17 --- lib/Value/Real.pm +++ lib/Value/Real.pm @@ -40,7 +40,7 @@ my $x = shift; $x = [$x,@_] if scalar(@_) > 0; return $x if ref($x) eq $pkg; $x = [$x] unless ref($x) eq 'ARRAY'; - Value::Error("Can't convert ARRAY of length ".scalar(@{$x})." to ".Value::showClass($class)) + Value::Error("Can't convert ARRAY of length %d to %s",scalar(@{$x}),Value::showClass($class)) unless (scalar(@{$x}) == 1); if (Value::isRealNumber($x->[0])) { return $self->formula($x->[0]) if Value::isFormula($x->[0]); @@ -48,7 +48,7 @@ } $x = Value::makeValue($x->[0]); return $x if Value::isRealNumber($x); - Value::Error("Can't convert ".Value::showClass($x)." to ".Value::showClass($class)); + Value::Error("Can't convert %s to %s",Value::showClass($x),Value::showClass($class)); } # Index: Complex.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Complex.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -Llib/Value/Complex.pm -Llib/Value/Complex.pm -u -r1.16 -r1.17 --- lib/Value/Complex.pm +++ lib/Value/Complex.pm @@ -42,13 +42,13 @@ my $x = shift; $x = [$x,@_] if scalar(@_) > 0; $x = $x->data if ref($x) eq $pkg || Value::isReal($x); $x = [$x] unless ref($x) eq 'ARRAY'; $x->[1] = 0 unless defined($x->[1]); - Value::Error("Can't convert ARRAY of length ".scalar(@{$x})." to a Complex Number") + Value::Error("Can't convert ARRAY of length %d to a Complex Number",scalar(@{$x})) unless (scalar(@{$x}) == 2); $x->[0] = Value::makeValue($x->[0]); $x->[1] = Value::makeValue($x->[1]); return $x->[0] if Value::isComplex($x->[0]) && scalar(@_) == 0; - Value::Error("Real part can't be ".Value::showClass($x->[0])) + Value::Error("Real part can't be %s",Value::showClass($x->[0])) unless (Value::isRealNumber($x->[0])); - Value::Error("Imaginary part can't be ".Value::showClass($x->[1])) + Value::Error("Imaginary part can't be %s",Value::showClass($x->[1])) unless (Value::isRealNumber($x->[1])); return $self->formula($x) if Value::isFormula($x->[0]) || Value::isFormula($x->[1]); bless {data => $x}, $class; Index: Context.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Context.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -Llib/Value/Context.pm -Llib/Value/Context.pm -u -r1.4 -r1.5 --- lib/Value/Context.pm +++ lib/Value/Context.pm @@ -26,6 +26,7 @@ pos => undef, message => '', flag => 0, + msg => {}, # for localization }, data => { hashes => ['lists'], @@ -100,6 +101,7 @@ $error->{string} = ''; $error->{pos} = undef; $error->{message} = ''; + $error->{original} = ''; $error->{flag} = 0; } @@ -108,9 +110,17 @@ # sub setError { my $error = (shift)->{error}; - $error->{message} = shift; - $error->{string} = shift; - $error->{pos} = shift; + my ($message,$string,$pos,$more) = @_; + my @args = (); + ($message,@args) = @{$message} if ref($message) eq 'ARRAY'; + $error->{original} = $message; + while ($message && $error->{msg}{$message}) {$message = $error->{msg}{$message}} + while ($more && $error->{msg}{$more}) {$more = $error->{msg}{$more}} + $message = sprintf($message,@args) if scalar(@args) > 0; + $message .= sprintf($more,$pos->[0]+1) if $more; + $error->{message} = $message; + $error->{string} = $string; + $error->{pos} = $string; $error->{flag} = 1; } Index: String.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/String.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -Llib/Value/String.pm -Llib/Value/String.pm -u -r1.6 -r1.7 --- lib/Value/String.pm +++ lib/Value/String.pm @@ -25,7 +25,7 @@ my $strings = $$Value::context->{strings}; if (!$strings->{$x}) { my $X = $strings->{uc($x)}; - Value::Error("String constant '$x' is not defined in this context") + Value::Error("String constant '%s' is not defined in this context",$x) unless $X && !$X->{caseSensitive}; $x = uc($x); while ($strings->{$x}{alias}) {$x = $strings->{$x}{alias}} } Index: Infinity.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Infinity.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/Value/Infinity.pm -Llib/Value/Infinity.pm -u -r1.7 -r1.8 --- lib/Value/Infinity.pm +++ lib/Value/Infinity.pm @@ -46,7 +46,7 @@ my $x = shift; $x = [$x,@_] if scalar(@_) > 0; $x = Value::makeValue($x); return $x if ref($x) eq $pkg || Value::isReal($x); - Value::Error("Can't convert '$x' to Infinity"); + Value::Error("Can't convert '%s' to Infinity",$x); } ############################################ Index: Vector.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Vector.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -Llib/Value/Vector.pm -Llib/Value/Vector.pm -u -r1.17 -r1.18 --- lib/Value/Vector.pm +++ lib/Value/Vector.pm @@ -48,7 +48,7 @@ foreach my $x (@{$p}) { $x = Value::makeValue($x); $isFormula = 1 if Value::isFormula($x); - Value::Error("Coordinate of Vector can't be ".Value::showClass($x)) + Value::Error("Coordinate of Vector can't be %s",Value::showClass($x)) unless Value::isNumber($x); } } @@ -73,7 +73,7 @@ return $pkg->new($x,@_) if scalar(@_) > 0 || ref($x) eq 'ARRAY'; return $x if ref($x) eq $pkg; return $pkg->make(@{$x->data}) if Value::class($x) eq 'Point'; - Value::Error("Can't convert ".Value::showClass($x)." to a Vector"); + Value::Error("Can't convert %s to a Vector",Value::showClass($x)); } ############################################ Index: AnswerChecker.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/AnswerChecker.pm,v retrieving revision 1.48 retrieving revision 1.49 diff -Llib/Value/AnswerChecker.pm -Llib/Value/AnswerChecker.pm -u -r1.48 -r1.49 --- lib/Value/AnswerChecker.pm +++ lib/Value/AnswerChecker.pm @@ -162,8 +162,8 @@ return eval {$self == $other} unless ref($ans->{checker}) eq 'CODE'; my $equal = eval {&{$ans->{checker}}($self,$other,$ans)}; if (!defined($equal) && $@ ne '' && (!$$Value::context->{error}{flag} || $ans->{showAllErrors})) { - $$Value::context->setError("<I>An error occurred while checking your answer:</I>\n". - '<DIV STYLE="margin-left:1em">'.$@.'</DIV>',''); + $$Value::context->setError(["<I>An error occurred while checking your answer:</I>\n". + '<DIV STYLE="margin-left:1em">%s</DIV>',$@],''); $$Value::context->{error}{flag} = $CMP_ERROR; warn "Please inform your instructor that an error occurred while checking your answer"; } @@ -742,7 +742,7 @@ my $def = ($self->{context} || $$Value::context)->lists->get('Matrix'); my $open = $self->{open} || $def->{open}; my $close = $self->{close} || $def->{close}; my @d = $self->dimensions; - Value::Error("Can't create ans_array for ".scalar(@d)."-dimensional matrix") + Value::Error("Can't create ans_array for %d-dimensional matrix",scalar(@d)) if (scalar(@d) > 2); @d = (1,@d) if (scalar(@d) == 1); $self->ans_matrix($extend,$name,@d,$size,$open,$close,''); Index: Formula.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Formula.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -Llib/Value/Formula.pm -Llib/Value/Formula.pm -u -r1.30 -r1.31 --- lib/Value/Formula.pm +++ lib/Value/Formula.pm @@ -227,7 +227,7 @@ $v = eval {&$f(@{$p},@zeros)}; if (!defined($v) && !$checkUndef) { return unless $showError; - Value::Error("Can't evaluate formula on test point (".join(',',@{$p}).")"); + Value::Error("Can't evaluate formula on test point (%s)",join(',',@{$p})); } push @{$values}, (defined($v)? Value::makeValue($v): $UNDEF); } @@ -255,8 +255,8 @@ $v = eval {&$f(@{$p},@adapt)}; if (!defined($v)) { return unless $showError; - Value::Error("Can't evaluate formula on test point (".join(',',@{$p}).") ". - "with parameters (".join(',',@adapt).")"); + Value::Error("Can't evaluate formula on test point (%s) with parameters (%s)", + join(',',@{$p}),join(',',@adapt)); } push @{$values}, Value::makeValue($v); } @@ -423,10 +423,10 @@ my @a; my $i = 0; my $max = Value::Real->new($l->getFlag('max_adapt',1E8)); foreach my $row (@{$B->[0]}) { if (abs($row->[0]) > $max) { - $l->Error("Constant of integration is too large: ".$row->[0]->string."\n". - "(maximum allowed is ".$max->string.")") if ($params[$i] eq 'C0'); - $l->Error("Adaptive constant is too large: $params[$i] = ".$row->[0]->string."\n". - "(maximum allowed is ".$max->string.")"); + $l->Error("Constant of integration is too large: %s\n(maximum allowed is %s)", + $row->[0]->string,$max->string) if ($params[$i] eq 'C0'); + $l->Error("Adaptive constant is too large: %s = %s\n(maximum allowed is %s)", + $params[$i],$row->[0]->string,$max->string); } push @a, $row->[0]; $i++; } Index: Interval.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Interval.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -Llib/Value/Interval.pm -Llib/Value/Interval.pm -u -r1.18 -r1.19 --- lib/Value/Interval.pm +++ lib/Value/Interval.pm @@ -140,7 +140,7 @@ return $pkg->new($open,@{$x->data},$close) if Value::class($x) =~ m/^(Point|List)$/ && $x->length == 2 && ($open eq '(' || $open eq '[') && ($close eq ')' || $close eq ']'); - Value::Error("Can't convert ".Value::showClass($x)." to an Interval"); + Value::Error("Can't convert %s to an Interval",Value::showClass($x)); } ############################################ Index: Matrix.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Matrix.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -Llib/Value/Matrix.pm -Llib/Value/Matrix.pm -u -r1.19 -r1.20 --- lib/Value/Matrix.pm +++ lib/Value/Matrix.pm @@ -170,7 +170,7 @@ return $pkg->new($x,@_) if scalar(@_) > 0 || ref($x) eq 'ARRAY'; return $x if ref($x) eq $pkg; return $pkg->make(@{$x->data}) if Value::class($x) =~ m/Point|Vector/; - Value::Error("Can't convert ".Value::showClass($x)." to a Matrix"); + Value::Error("Can't convert %s to a Matrix",Value::showClass($x)); } ############################################ @@ -223,7 +223,7 @@ if (scalar(@dl) == 1) {@dl = (1,@dl); $l = $pkg->make($l)} if (scalar(@dr) == 1) {@dr = (@dr,1); $r = $pkg->make($r)->transpose} Value::Error("Can only multiply 2-dimensional matrices") if scalar(@dl) > 2 || scalar(@dr) > 2; - Value::Error("Matices of dimensions $dl[0]x$dl[1] and $dr[0]x$dr[1] can't be multiplied") + Value::Error("Matices of dimensions %dx%d and %dx%d can't be multiplied",@dl,@dr) unless ($dl[1] == $dr[0]); # # Do matrix multiplication @@ -297,7 +297,7 @@ my $self = shift; my @d = $self->dimensions; if (scalar(@d) == 1) {@d = (1,@d); $self = $pkg->make($self)} - Value::Error("Can't transpose ".scalar(@d)."-dimensional matrices") unless scalar(@d) == 2; + Value::Error("Can't transpose %d-dimensional matrices",scalar(@d)) unless scalar(@d) == 2; my @M = (); my $M = $self->data; foreach my $j (0..$d[1]-1) { my @row = (); Index: Point.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Point.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -Llib/Value/Point.pm -Llib/Value/Point.pm -u -r1.15 -r1.16 --- lib/Value/Point.pm +++ lib/Value/Point.pm @@ -49,7 +49,7 @@ foreach my $x (@{$p}) { $x = Value::makeValue($x); $isFormula = 1 if Value::isFormula($x); - Value::Error("Coordinate of Point can't be ".Value::showClass($x)) + Value::Error("Coordinate of Point can't be %s",Value::showClass($x)) unless Value::isNumber($x); } } @@ -64,7 +64,7 @@ my $x = shift; return $pkg->new($x,@_) if scalar(@_) > 0 || ref($x) eq 'ARRAY'; return $x if ref($x) eq $pkg; - Value::Error("Can't convert ".Value::showClass($x)." to a Point"); + Value::Error("Can't convert %s to a Point",Value::showClass($x)); } ############################################ Index: Value.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value.pm,v retrieving revision 1.38 retrieving revision 1.39 diff -Llib/Value.pm -Llib/Value.pm -u -r1.38 -r1.39 --- lib/Value.pm +++ lib/Value.pm @@ -147,7 +147,7 @@ return Value::String->make($x) if (!$Parser::installed || $$Value::context->{strings}{$x}); return $x if !$params{makeFormula}; - Value::Error("String constant '$x' is not defined in this context") + Value::Error("String constant '%s' is not defined in this context",$x) if $params{showError}; $x = Value::Formula->new($x); $x = $x->eval if $x->isConstant; @@ -233,7 +233,7 @@ elsif ($type eq 'Infinity') {$type = $Value::Type{infinity}} elsif ($type eq 'value' || $type eq 'Formula') {$type = $value->typeRef} elsif ($type eq 'unknown') { - $equation->Error("Can't convert ".Value::showClass($value)." to a constant"); + $equation->Error("Can't convert %s to a constant",Value::showClass($value)); } else { $type = 'Value::'.$type, $value = $type->new(@{$value}); $type = $value->typeRef; @@ -354,7 +354,7 @@ @indices = $_[0]->value if scalar(@_) == 1 && Value::isValue($_[0]); while (scalar(@indices) > 0) { $i = shift @indices; $i-- if $i > 0; $i = $i->value if Value::isValue($i); - Value::Error("Can't extract element number '$i' (index must be an integer)") + Value::Error("Can't extract element number '%s' (index must be an integer)",$i) unless $i =~ m/^-?\d+$/; $M = $M->data->[$i]; } @@ -382,9 +382,9 @@ my ($l,$r,$flag,$op) = @_; my $call = $$context->{method}{$op}; if (defined($call) && $l->promotePrecedence($r)) {return $r->$call($l,!$flag)} - my $error = "Can't use '$op' with ".$l->class."-valued operands"; + my $error = "Can't use '%s' with %s-valued operands"; $error .= " (use '**' for exponentiation)" if $op eq '^'; - Value::Error($error); + Value::Error($error,$op,$l->class); } # @@ -489,7 +489,7 @@ sub reduce {shift} sub ijk { - Value::Error("Can't use method 'ijk' with objects of type '".(shift)->class."'"); + Value::Error("Can't use method 'ijk' with objects of type '%s'",(shift)->class); } # @@ -497,7 +497,9 @@ # sub Error { my $message = shift; + $message = [$message,@_] if (scalar(@_)); $$context->setError($message,''); + $message = $$context->{error}{message}; die $message . traceback() if $$context->{debug}; die $message . getCaller(); } Index: Parser.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -Llib/Parser.pm -Llib/Parser.pm -u -r1.25 -r1.26 --- lib/Parser.pm +++ lib/Parser.pm @@ -106,7 +106,7 @@ /var/ and do {$self->Var($ref->[1]); last}; /fn/ and do {$self->Fn($ref->[1]); last}; /str/ and do {$self->Str($ref->[1]); last}; - /error/ and do {$self->Error("Unexpected character '$ref->[1]'",$ref); last}; + /error/ and do {$self->Error(["Unexpected character '%s'",$ref->[1]],$ref); last}; } return if ($self->{error}); } @@ -139,14 +139,15 @@ # sub Error { my $self = shift; my $context = $self->{context}; - my $message = shift; my $ref = shift; my $string; + my $message = shift; my $ref = shift; + my $string; my $more = ""; if ($ref) { - $message .= "; see position ".($ref->[2]+1)." of formula"; + $more = "; see position %d of formula"; $string = $self->{string}; $ref = [$ref->[2],$ref->[3]]; } - $context->setError($message,$string,$ref); - die $message . Value::getCaller(); + $context->setError($message,$string,$ref,$more); + die $context->{error}{message} . Value::getCaller(); } # @@ -247,9 +248,9 @@ $self->pushOperator($name,$op->{precedence},1); } else { my $top = $self->top; - $self->Error("Function '$top->{name}' is missing its input(s)",$top->{ref}); + $self->Error(["Function '%s' is missing its input(s)",$top->{name}],$top->{ref}); } - } else {$self->Error("Missing operand before '$name'",$ref)} + } else {$self->Error(["Missing operand before '%s'",$name],$ref)} } } @@ -324,8 +325,8 @@ if ($paren->{emptyOK} && $paren->{close} eq $type) { $self->pushOperand($parser->{List}->new($self,[],1,$paren)) } - elsif ($type eq 'start') {$self->Error("Missing close parenthesis for '$top->{value}'",$top->{ref})} - elsif ($top->{value} eq 'start') {$self->Error("Extra close parenthesis '$type'",$ref)} + elsif ($type eq 'start') {$self->Error(["Missing close parenthesis for '%s'",$top->{value}],$top->{ref})} + elsif ($top->{value} eq 'start') {$self->Error(["Extra close parenthesis '%s'",$type],$ref)} else {$top->{ref}[3]=$ref->[3]; $self->Error("Empty parentheses",$top->{ref})} last; }; @@ -352,9 +353,9 @@ $paren,$top->entryType,$open,$type)); } else { my $prev = $self->prev; - if ($type eq "start") {$self->Error("Missing close parenthesis for '$prev->{value}'",$prev->{ref})} - elsif ($prev->{value} eq "start") {$self->Error("Extra close parenthesis '$type'",$ref)} - else {$self->Error("Mismatched parentheses: '$prev->{value}' and '$type'",$ref)} + if ($type eq "start") {$self->Error(["Missing close parenthesis for '%s'",$prev->{value}],$prev->{ref})} + elsif ($prev->{value} eq "start") {$self->Error(["Extra close parenthesis '%s'",$type],$ref)} + else {$self->Error(["Mismatched parentheses: '%s' and '%s'",$prev->{value},$type],$ref)} return; } last; @@ -362,13 +363,13 @@ /fn/ and do { my $top = $self->top; - $self->Error("Function '$top->{name}' is missing its input(s)",$top->{ref}); + $self->Error(["Function '%s' is missing its input(s)",$top->{name}],$top->{ref}); return; }; /operator/ and do { my $top = $self->top(); my $name = $top->{name}; $name =~ s/^u//; - $self->Error("Missing operand after '$name'",$top->{ref}); + $self->Error(["Missing operand after '%s'",$name],$top->{ref}); return; }; } @@ -562,7 +563,7 @@ my $self = shift; $self->setValues(@_); foreach my $x (keys %{$self->{values}}) { - $self->Error("The value of '$x' can't be a formula") + $self->Error(["The value of '%s' can't be a formula",$x]) if Value::isFormula($self->{values}{$x}); } Value::makeValue($self->{tree}->eval); @@ -667,11 +668,11 @@ my $variables = $self->{context}{variables}; $self->{values} = {@_}; foreach my $x (keys %{$self->{values}}) { - $self->Error("Undeclared variable '$x'") unless defined $variables->{$x}; + $self->Error(["Undeclared variable '%s'",$x]) unless defined $variables->{$x}; $value = Value::makeValue($self->{values}{$x}); $value = Value::Formula->new($value) unless Value::isValue($value); ($value,$type) = Value::getValueType($self,$value); - $self->Error("Variable '$x' should be of type $variables->{$x}{type}{name}") + $self->Error(["Variable '%s' should be of type %s",$x,$variables->{$x}{type}{name}]) unless Parser::Item::typeMatch($type,$variables->{$x}{type}); $self->{values}{$x} = $value; } Index: Value.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Value.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -Llib/Parser/Value.pm -Llib/Parser/Value.pm -u -r1.12 -r1.13 --- lib/Parser/Value.pm +++ lib/Parser/Value.pm @@ -28,7 +28,7 @@ return $parser->{Number}->new($equation,$value,$ref) if ($type eq 'Number'); return $parser->{Number}->new($equation,$value->{data},$ref) if ($type eq 'value' && $value->class eq 'Complex'); - $equation->Error("Can't convert ".Value::showClass($value)." to a constant",$ref) + $equation->Error(["Can't convert %s to a constant",Value::showClass($value)],$ref) if ($type eq 'unknown'); $type = 'Value::'.$type, $value = $type->new(@{$value}) unless $type eq 'value'; $type = $value->typeRef; Index: List.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/List.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -Llib/Parser/List.pm -Llib/Parser/List.pm -u -r1.13 -r1.14 --- lib/Parser/List.pm +++ lib/Parser/List.pm @@ -42,7 +42,7 @@ if ($paren->{formList}) {$type->{name} = 'List'} elsif ($type->{name} eq 'Point') { $equation->Error("Entries in a Matrix must be of the same type and length")} - else {$equation->Error("Entries in a $type->{name} must be of the same type")} + else {$equation->Error(["Entries in a %s must be of the same type",$type->{name}])} } } $list = bless { Index: Context.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -Llib/Parser/Context.pm -Llib/Parser/Context.pm -u -r1.12 -r1.13 --- lib/Parser/Context.pm +++ lib/Parser/Context.pm @@ -100,7 +100,7 @@ if (!ref($context)) { my $name = $context; $context = Parser::Context->get($contextTable,$context); - Value::Error("Unknown context '$name'") unless defined($context); + Value::Error("Unknown context '%s'",$name) unless defined($context); } $contextTable->{current} = $context; $Value::context = \$contextTable->{current}; Index: Differentiation.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Differentiation.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -Llib/Parser/Differentiation.pm -Llib/Parser/Differentiation.pm -u -r1.5 -r1.6 --- lib/Parser/Differentiation.pm +++ lib/Parser/Differentiation.pm @@ -31,7 +31,7 @@ sub Item::D { my $self = shift; my $type = ref($self); $type =~ s/.*:://; - $self->Error("Differentiation for '$type' is not implemented"); + $self->Error("Differentiation for '%s' is not implemented",$type); } @@ -154,7 +154,7 @@ sub Parser::Function::D { my $self = shift; - $self->Error("Differentiation of '$self->{name}' not implemented"); + $self->Error("Differentiation of '%s' not implemented",$self->{name}); } sub Parser::Function::D_chain { Index: BOP.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/BOP.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -Llib/Parser/BOP.pm -Llib/Parser/BOP.pm -u -r1.11 -r1.12 --- lib/Parser/BOP.pm +++ lib/Parser/BOP.pm @@ -117,12 +117,12 @@ my $ltype = $self->{lop}->typeRef; my $rtype = $self->{rop}->typeRef; my $name = $self->{def}{string} || $self->{bop}; if ($ltype->{name} eq 'String') { - $self->Error("Operands of '$name' can't be ". + $self->Error("Operands of '%s' can't be %s",$name, ($self->{lop}{isInfinite}? 'infinities': 'words')); return 1; } if ($rtype->{name} eq 'String') { - $self->Error("Operands of '$name' can't be ". + $self->Error("Operands of '%s' can't be %s",$name, ($self->{rop}{isInfinite}? 'infinities': 'words')); return 1; } @@ -137,7 +137,7 @@ my $ltype = $self->{lop}->typeRef; my $rtype = $self->{rop}->typeRef; return 0 if ($ltype->{name} ne 'List' and $rtype->{name} ne 'List'); my $name = $self->{def}{string} || $self->{bop}; - $self->Error("Operands of '$name' can't be lists"); + $self->Error("Operands of '%s' can't be lists",$name); return 1; } @@ -170,7 +170,7 @@ if ($lc == $rr) { my $rowType = Value::Type('Matrix',$rc,$Value::Type{number},formMatrix=>1); $self->{type} = Value::Type('Matrix',$lr,$rowType,formMatrix=>1); - } else {$self->Error("Matrix of dimensions ${lr}x${lc} and ${rr}x${rc} can't be multiplied")} + } else {$self->Error("Matrices of dimensions %dx%d and %dx%d can't be multiplied",$lr,$lc,$rr,$rc)} } else {$self->Error("Matrices are too deep to be multiplied")} } @@ -204,8 +204,8 @@ my ($ltype,$rtype) = @_; my ($op,$ref) = ($self->{bop}); if ($ltype->{name} eq $rtype->{name}) - {$self->Error("Operands for '$op' must be of the same length")} - else {$self->Error("Operands for '$op' must be of the same type")} + {$self->Error("Operands for '%s' must be of the same length",$op)} + else {$self->Error("Operands for '%s' must be of the same type",$op)} } ################################################## Index: Variable.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Variable.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/Parser/Variable.pm -Llib/Parser/Variable.pm -u -r1.7 -r1.8 --- lib/Parser/Variable.pm +++ lib/Parser/Variable.pm @@ -20,11 +20,11 @@ my $string = substr($equation->{string},$ref->[2]); if ($string =~ m/^([a-z][a-z]+)/i) { $ref->[3] = $ref->[2]+length($1); - $equation->Error("'$1' is not defined in this context",$ref); + $equation->Error(["'%s' is not defined in this context",$1],$ref); } - $equation->Error("Variable '$name' is not defined in this context",$ref); + $equation->Error(["Variable '%s' is not defined in this context",$name],$ref); } - $equation->Error("Variable '$name' is not defined in this context",$ref) + $equation->Error(["Variable '%s' is not defined in this context",$name],$ref) if $equation->{context}{variables}{$name}{parameter} && $equation->{context}{flags}{no_parameters}; $equation->{variables}{$name} = 1; @@ -64,7 +64,7 @@ my $self = shift; my $value = $self->{equation}{values}{$self->{name}}; return $value if defined($value); - $self->Error("No value given for variable '$self->{name}'"); + $self->Error("No value given for variable '%s'",$self->{name}); } # Index: Function.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Function.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -Llib/Parser/Function.pm -Llib/Parser/Function.pm -u -r1.12 -r1.13 --- lib/Parser/Function.pm +++ lib/Parser/Function.pm @@ -41,7 +41,7 @@ foreach my $x (@{$self->{params}}) {push(@params,$x->eval)} my $result = eval {$self->_eval(@params)}; return $result unless $@; - $self->Error("Can't take $self->{name} of ".join(',',@params)); + $self->Error("Can't take %s of %s",$self->{name},join(',',@params)); } # # Stub for sub-classes @@ -103,14 +103,14 @@ my $self = shift; my $name = shift; my $context = Parser::Context->current; my $fn = $context->{functions}{$name}; - Value::Error("No definition for function '$name'") unless defined($fn); + Value::Error("No definition for function '%s'",$name) unless defined($fn); my $isFormula = 0; foreach my $x (@_) {return $self->formula($name,@_) if Value::isFormula($x)} my $class = $fn->{class}; my $result = eval {$class->_call($name,@_)}; return $result unless $@; Value::Error($context->{error}{message}) if $context->{error}{message}; - Value::Error("Can't take $name of ".join(',',@_)); + Value::Error("Can't take %s of %s",$name,join(',',@_)); } # # Stub for sub-classes. @@ -145,10 +145,10 @@ my $arg = $self->{params}->[0]; if ($arg->isComplex) { if (!($self->{def}{nocomplex})) {$self->{type} = $Value::Type{complex}} - else {$self->Error("Function '$self->{name}' doesn't accept Complex inputs")} + else {$self->Error("Function '%s' doesn't accept Complex inputs",$self->{name})} } elsif ($arg->isNumber) { $self->{type} = $Value::Type{number}; - } else {$self->Error("The input for '$self->{name}' must be a number")} + } else {$self->Error("The input for '%s' must be a number",$self->{name})} } # @@ -159,7 +159,7 @@ return if ($self->checkArgCount(1)); if ($self->{params}->[0]->type =~ m/Point|Vector/) { $self->{type} = $Value::Type{number}; - } else {$self->Error("Function '$self->{name}' requires a Vector input")} + } else {$self->Error("Function '%s' requires a Vector input",$self->{name})} } # @@ -171,7 +171,7 @@ return if ($self->checkArgCount(1)); if ($self->{params}->[0]->isNumber) { $self->{type} = $Value::Type{number}; - } else {$self->Error("Function '$self->{name}' requires a Complex input")} + } else {$self->Error("Function '%s' requires a Complex input",$self->{name})} } # @@ -183,7 +183,7 @@ return if ($self->checkArgCount(1)); if ($self->{params}->[0]->isNumber) { $self->{type} = $Value::Type{complex}; - } else {$self->Error("Function '$self->{name}' requires a Complex input")} + } else {$self->Error("Function '%s' requires a Complex input",$self->{name})} } ################################################## @@ -211,11 +211,11 @@ my $args = scalar(@{$self->{params}}); if ($args == $count) { return 0 if ($count == 0 || $self->{params}->[0]->length > 0); - $self->Error("Function '$name' requires a non-empty input list"); + $self->Error("Function '%s' requires a non-empty input list",$name); } elsif ($args < $count) { - $self->Error("Function '$name' has too few inputs"); + $self->Error("Function '%s' has too few inputs",$name); } else { - $self->Error("Function '$name' has too many inputs"); + $self->Error("Function '%s' has too many inputs",$name); } return 1; } Index: Item.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Item.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -Llib/Parser/Item.pm -Llib/Parser/Item.pm -u -r1.6 -r1.7 --- lib/Parser/Item.pm +++ lib/Parser/Item.pm @@ -84,7 +84,7 @@ sub ijk { my $self = shift; - $self->Error("Can't use method 'ijk' with objects of type '".$self->type."'"); + $self->Error("Can't use method 'ijk' with objects of type '%s'",$self->type); } # @@ -107,8 +107,9 @@ # sub Error { my $self = shift; - $self->{equation}->Error(@_,$self->{ref}) if defined($self->{equation}); - Parser->Error(@_); + my $message = shift; $message = [$message,@_] if scalar(@_) > 0; + $self->{equation}->Error($message,$self->{ref}) if defined($self->{equation}); + Parser->Error($message); } ######################################################################### Index: UOP.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/UOP.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -Llib/Parser/UOP.pm -Llib/Parser/UOP.pm -u -r1.12 -r1.13 --- lib/Parser/UOP.pm +++ lib/Parser/UOP.pm @@ -97,7 +97,7 @@ my $type = $self->{op}->typeRef; return 0 if ($type->{name} ne 'String'); my $name = $self->{def}{string} || $self->{uop}; - $self->Error("Operand of '$name' can't be ". + $self->Error("Operand of '%s' can't be %s",$name, ($self->{op}{isInfinite}? 'an infinity': 'a word')); return 1; } @@ -110,7 +110,7 @@ my $type = $self->{op}->typeRef; return 0 if ($type->{name} ne 'List'); my $name = $self->{def}{string} || $self->{uop}; - $self->Error("Operand of '$name' can't be a list"); + $self->Error("Operand of '%s' can't be a list",$name); return 1; } Index: LimitedNumeric.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Legacy/LimitedNumeric.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -Llib/Parser/Legacy/LimitedNumeric.pm -Llib/Parser/Legacy/LimitedNumeric.pm -u -r1.1 -r1.2 --- lib/Parser/Legacy/LimitedNumeric.pm +++ lib/Parser/Legacy/LimitedNumeric.pm @@ -22,7 +22,7 @@ my $self = shift; $self->SUPER::_check; my $uop = $self->{def}{string} || $self->{uop}; - $self->Error("You can only use '$uop' with (non-negative) numbers") + $self->Error("You can only use '%s' with (non-negative) numbers",$uop) unless $self->{op}->class =~ /Number|DIVIDE/; } @@ -40,7 +40,7 @@ my $self = shift; $self->SUPER::_check; my $bop = $self->{def}{string} || $self->{bop}; - $self->Error("You can only use '$bop' between (non-negative) numbers") + $self->Error("You can only use '%s' between (non-negative) numbers",$bop) unless $self->{lop}->class =~ /Number|MINUS/ && $self->{rop}->class eq 'Number'; } Index: NumberWithUnits.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Legacy/NumberWithUnits.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -Llib/Parser/Legacy/NumberWithUnits.pm -Llib/Parser/Legacy/NumberWithUnits.pm -u -r1.1 -r1.2 --- lib/Parser/Legacy/NumberWithUnits.pm +++ lib/Parser/Legacy/NumberWithUnits.pm @@ -16,7 +16,7 @@ Value::Error("You must provide units for your number") unless $units; $num = Value::makeValue($num); - Value::Error("A number with units must be a constant, not ".lc(Value::showClass($num))) + Value::Error("A number with units must be a constant, not %s",lc(Value::showClass($num))) unless Value::isReal($num); my %Units = getUnits($units); Value::Error($Units{ERROR}) if ($Units{ERROR}); Index: Data.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Context/Data.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -Llib/Value/Context/Data.pm -Llib/Value/Context/Data.pm -u -r1.5 -r1.6 --- lib/Value/Context/Data.pm +++ lib/Value/Context/Data.pm @@ -89,7 +89,7 @@ my $self = shift; my %D = (@_); return if scalar(@_) == 0; my $data = $self->{context}{$self->{dataName}}; foreach my $x (keys %D) { - Value::Error("Illegal $self->{name} name '$x'") unless $x =~ m/^$self->{namePattern}$/; + Value::Error("Illegal %s name '%s'",$self->{name},$x) unless $x =~ m/^$self->{namePattern}$/; warn "$self->{Name} '$x' already exists" if defined($data->{$x}); $data->{$x} = $self->create($D{$x}); } |