[tools] testbot/cgi: Allow calling AddError() without an error.
This simplifies error handling for APIs that just return an error message. Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com> --- testbot/lib/ObjectModel/CGI/Page.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/testbot/lib/ObjectModel/CGI/Page.pm b/testbot/lib/ObjectModel/CGI/Page.pm index 1df5392930..a8268754ac 100644 --- a/testbot/lib/ObjectModel/CGI/Page.pm +++ b/testbot/lib/ObjectModel/CGI/Page.pm @@ -356,6 +356,7 @@ Sets the error message to be shown to the user. =item ErrMessage A message to be shown on the page that describes why the form data is invalid. This should include the display name of the field(s) that need to be fixed. +If this parameter is false the error message is not modified. =item ErrField If the error concerns a specific field, the name of that field. This can be @@ -363,6 +364,9 @@ used by the page to highlight the field that needs to be corrected. =back +Returns the ErrMessage parameter. This allows checking whether an error +was actually added. + =back =cut @@ -370,8 +374,12 @@ sub AddError($$;$) { my ($self, $ErrMessage, $ErrField) = @_; - $self->{ErrMessage} = $ErrMessage; - $self->{ErrField} = $ErrField; + if ($ErrMessage) + { + $self->{ErrMessage} = $ErrMessage; + $self->{ErrField} = $ErrField; + } + return $ErrMessage; } # FIXME: For legacy code, to be removed. -- 2.30.2
participants (1)
-
Francois Gouget