Tutorial 15 - Logging errors

Scribe provides a number of different ways for tracking and logging error conditions that may arise in the course of Process or Report execution. In this Tutorial, we will build on the MailCustomerOrderInfo process, and add components to catch the errors.

First, we will check if the CustomerFormatted function produced any report at all, since not every Customer stored in the Customers table has a purchase history with Northwind Traders Company. For customers with no history, the returned Report variable will be empty. The way to check this condition is to compare the variable with a built-in constant EMPTY (incidentally, any variable of any data type that has not yet been set to any value will equal EMPTY):

Next, if the report is indeed empty, we do not want to send an empty e-mail to the customer. Instead, it would be better to log this so that a corrective action can be taken later on. In Tutorial 14 the error conditions were logged by inserting a record in the MailErrorLog table. In this Tutorial, we will make use of another Scribe component: Alert.

The Alert component provides means of interaction with the user. When executed, it displays an Alert panel with a number of dismissal buttons; the procedure execution is halted until the user presses one of the buttons. The Alert component many not have any buttons at all, in which case it allows the procedure to continue after the display of the Alert panel.

The Body of the Alert component is what is displayed in the Alert panel's window, and the Heading is shown in the panel's title bar. The Body text can incorporate procedure variables (their names are enclosed into square brackets) and thus have its content defined at the run-time, as shown in the figure below:

The complete procedure is shown below:

(Click on the image to enlarge)

Save the Process Procedure as MailCustomerOrderInfoLog2.

When the process is executed in the foreground, the Alert component displays the Alert panel. However, in the background execution, the component logs the message (with the text content taken from the component's Body) in the Server's volatile memory; the log can be viewed from the Saved Processes window:

Note that if the background process logs a message, its status upon completion is shown as "Failed", even though some parts of the process produced normal results.