Generazione di un messaggio personalizzato

I client ClearQuest per Web e Eclipse permettono agli hook di presentare messaggi di errore, di avvertenza e informativi agli utenti grazie all'inclusione di parametri per i messaggi di avviso in un normale messaggio di errore hook. Tuttavia, poiché il client ClearQuest per Windows, gli script scritti dagli utenti e i client più obsoleti potrebbero non riconoscere i parametri dei messaggi di avviso, a questa capacità è opportuno accedere dall'hook globale riportato di seguito, dopo averlo aggiunto allo schema. L'hook utilizza i parametri messaggio in una normale istruzione die se il client non supporta i messaggi personalizzati, ma termina con un messaggio personalizzato se il client lo supporta.

É possibile richiamare la funzione DieWithCustomMessage di seguito da tutte le posizioni dove è possibile usare un'istruzione die, ed essa avrà lo stesso effetto di un'istruzione die sull'operazione corrente. Ad esempio, richiamare la funzione DieWithCustomMessage da un hook di controllo accessi indicherà un errore nello stesso modo in cui un'istruzione die indicherà un errore, ma con un messaggio personalizzato.

Per istruzioni sul download del codice hook globale, consultare la technote 1322606 alla pagina http://www.ibm.com/support/docview.wss?&rs=939&uid=swg21322606.

Esempi

Esempi Perl

sub Defect_generate_error_message {
  my($result);
  my($param) = @_;
  # record type name is Defect
  $error_summary="ReturnCustomErrorMessage";
  $error_details="Error message: Clicking this button will activate a computer virus!";
  # $result=&DieWithCustomMessage($error_summary,$error_details,"ERROR");
  DieWithCustomMessage("ERROR",$error_summary, $error_details);
  return $result;
}
sub Defect_generate_warning_message {
  my($result);
  my($param) = @_;
  # record type name is Defect
  $error_summary="ReturnCustomWarningMessage";
  $error_details="Warning message: Do not smoke at the work place!";
  DieWithCustomMessage("WARNING",$error_summary, $error_details);
  return $result;
}
sub Defect_generate_info_message {
  my($result);
  my($param) = @_;
  # record type name is Defect
  $error_summary="ReturnCustomInfoMessage";
  $error_details="Information message: Welcome to Beijing!";
  DieWithCustomMessage("INFO",$error_summary, $error_details);
  return $result;
}

Esempi VBScript

Function recordtype_ErrorMessage(param)
' param As Variant
' record type name is recordtype

REM add your hook code here

Dim error_summary
Dim error_details

error_summary="ReturnCustomErrorMessage"
error_details="Error message: Clicking this button will activate a computer virus!"

' $result=&DieWithCustomMessage($error_summary, $error_details,"ERROR");
call DieWithCustomMessage("ERROR",error_summary, error_details)
End Function
Function recordtype_WarningMessage(param)
' param As Variant
' record type name is recordtype

REM add your hook code here

Dim error_summary
Dim error_details

error_summary="ReturnCustomWarningMessage"
error_details="Warning message: Do not smoke at the work place!"

call DieWithCustomMessage("WARNING",error_summary, error_details)
End Function
Function recordtype_InfoMessage(param)
' param As Variant
' record type name is recordtype

REM add your hook code here

Dim error_summary
Dim error_details

error_summary="ReturnCustomInfoMessage"
error_details="Information message: Welcome to Beijing!" 

call DieWithCustomMessage("INFO",error_summary, error_details)
End Function

Feedback