Generating a custom message

The DevOps Plan application allows hooks to present error, warning, and information alert messages to users by embedding the alert message parameters within a normal hook error message. However, because the DevOps Plan application, user-written scripts, and older applications might not recognize the alert message parameters, this capability should be accessed through the global hook below, after adding it to your schema. If the application does not support custom messages, the hook uses the message parameters in a normal die statement. If the application does support custom messages, the hook uses the DieWithCustomMessage function.

The DieWithCustomMessage function below can be called from all places where a die statement can be used, and it will have the same effect as a die statement on the current operation. For example, calling the DieWithCustomMessage function from an access control hook would indicate failure in exactly the same way a die statement would indicate failure, but with a custom message.

Examples

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;
}