From: Sam H. v. a. <we...@ma...> - 2005-10-26 15:52:25
|
Log Message: ----------- added error checking to ensure that arguments to status lookup methods are defined. Modified Files: -------------- webwork2/lib/WeBWorK: CourseEnvironment.pm Revision Data ------------- Index: CourseEnvironment.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/CourseEnvironment.pm,v retrieving revision 1.29 retrieving revision 1.30 diff -Llib/WeBWorK/CourseEnvironment.pm -Llib/WeBWorK/CourseEnvironment.pm -u -r1.29 -r1.30 --- lib/WeBWorK/CourseEnvironment.pm +++ lib/WeBWorK/CourseEnvironment.pm @@ -253,6 +253,9 @@ sub status_abbrev_to_name { my ($ce, $status_abbrev) = @_; + croak "status_abbrev_to_name: status_abbrev (first argument) must be defined and non-empty" + if not defined $status_abbrev or $status_abbrev eq ""; + return $ce->{_status_abbrev_to_name}{$status_abbrev}; } @@ -265,6 +268,9 @@ sub status_name_to_abbrevs { my ($ce, $status_name) = @_; + croak "status_name_to_abbrevs: status_name (first argument) must be defined and non-empty" + if not defined $status_name or $status_name eq ""; + return unless exists $ce->{statuses}{$status_name}; return @{$ce->{statuses}{$status_name}{abbrevs}}; } @@ -277,6 +283,11 @@ sub status_has_behavior { my ($ce, $status_name, $behavior) = @_; + croak "status_has_behavior: status_name (first argument) must be defined and non-empty" + if not defined $status_name or $status_name eq ""; + croak "status_has_behavior: behavior (second argument) must be defined and non-empty" + if not defined $behavior or $behavior eq ""; + if (exists $ce->{statuses}{$status_name}) { if (exists $ce->{statuses}{$status_name}{behaviors}) { my $num_matches = grep { $_ eq $behavior } @{$ce->{statuses}{$status_name}{behaviors}}; @@ -298,6 +309,11 @@ sub status_abbrev_has_behavior { my ($ce, $status_abbrev, $behavior) = @_; + croak "status_abbrev_has_behavior: status_abbrev (first argument) must be defined and non-empty" + if not defined $status_abbrev or $status_abbrev eq ""; + croak "status_abbrev_has_behavior: behavior (second argument) must be defined and non-empty" + if not defined $behavior or $behavior eq ""; + return $ce->status_has_behavior($ce->status_abbrev_to_name($status_abbrev), $behavior); } |