Error checking and validation

For many methods and properties of the Rational® ClearQuest® API, you must check the return value to validate whether or not the call returns an error.

You should also write code to handle potential exception failures. Trap exceptions by executing API methods within an eval{} statement for Perl. For example,
# trap exceptions and error message strings
# ...
    eval { $RetVal = ${$CQEntity}->Validate(); };
    # EXCEPTION information is in $@
    # RetVal is either an empty string or contains a failure message string
    if ($@){
	print "Exception: '$@'\n";
	# other exception handling goes here...
	   }
    if ($RetVal eq "")
         {# success...
         }
    else {
	  # failure...
	  # return the message string  here...
	 }

For VBScript, use an On Error statement to trap exceptions. For more information, see VBScript error handling and Perl error handling. The Action commit hook example provides examples of error and exception handling when calling the Commit method.


Feedback