Francois Gouget : testbot/cgi: Allow calling AddError() without an error.
Alexandre Julliard
julliard at winehq.org
Wed Jul 6 12:02:25 CDT 2022
Module: tools
Branch: master
Commit: 71ff9805246dfd0834023c858f4f07bd7073056b
URL: https://source.winehq.org/git/tools.git/?a=commit;h=71ff9805246dfd0834023c858f4f07bd7073056b
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Wed Jul 6 16:06:21 2022 +0200
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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 1df53929..a8268754 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.
More information about the wine-cvs
mailing list