Example: Handling InsertData Method Failure

The following example demonstrates error handling when InsertData fails.

import PT_DIAGNOSTICS:*;

class TestFailedGetDiagnosticInfo extends PTDiagnostics
   /* Constructor */
   method TestFailedGetDiagnosticInfo();
   /* Public Method */
   method GetDiagnosticInfo();
   method IsPlugIn();
private
end-class;

method TestFailedGetDiagnosticInfo;
   Local boolean &status;
   %Super = create PTDiagnostics();
   &status = %Super.SetProperty(%This, "Purpose", "String",
 "This is a diagnostic to show how developers can trap a failure in
 GetDiagnosticInfo method and print out results to the web page.");
end-method;

method GetDiagnosticInfo
   Local string &sError, &sLicenseCode, &sLicenseGroup;
   Local boolean &status;
   SQLExec("SELECT LICENSE_CODE, LICENSE_GROUP FROM PSOPTIONS",
 &sLicenseCode, &sLicenseGroup);
   /* introduce unknown propFormat of String1 */
   &status = %Super.InsertData("String1",
 "Your License Code is: ", Upper(&sLicenseCode));
   If Not &status Then
      &status = %Super.InsertData("String", "Status Failed!",
 "This message will be printed out in the HTML page if
 something fails here.  This is expected behaviour.");
   End-If;
end-method;

method IsPlugIn
end-method;