Exception Class Methods
In this section, we discuss the Exception class methods, in alphabetical order.
Syntax
GetSubstitution(Index)
Description
When you create a message in the message catalog, you can specify values in the message text, such as %1, %2, and so on, that are replaced with values by the system at runtime. The value that gets put into the message text value is called the substitution string. The GetSubstitution method returns the substitution string in the error message specified by Index, with 1 being the first substitution string, 2 being the second, and so on.
Parameters
Field or Control |
Definition |
---|---|
Index |
Specify the substitution string number that you'd like to return. The first one is 1, the second is 2, and so on. You must specify a valid substitution string number, that is, you can't specify a 4 if there are only three substitution strings. |
Returns
The substitution text as a string.
Example
If &Ex1.MessageSetNumber = 2 and &Ex1.MessageNumber = 170 Then
/* Get Sendmail error */
&String = &Ex1.GetSubstitution(1);
/* do processing according to type of Sendmail error */
. . . .
End-if;
Syntax
Output()
Description
Use the Output method if you want to display the message associated with the exception to the user (in an online context), or have it logged (if offline). This is analogous to using the MessageBox function to log a message.
Parameters
None.
Returns
If called in an online context, display the message associated with the exception to the user. If called offline, record the exception for later display or analysis.
Example
catch Except2 &Ex2
&Ex2.Output(); /* tell about it */
Syntax
SetSubstitution(Index, String)
Description
When you create a message in the message catalog, you can specify values in the message text, such as %1, %2, and so on, that are replaced with values by the system at runtime. The value that gets put into the message text value is called the substitution string. The SetSubstitution method sets the substitution string in the error message specified by Index, with 1 being the first substitution string, 2 being the second, and so on.
Parameters
Field or Control |
Definition |
---|---|
Index |
Specify the substitution string number that you'd like to replace. The first one is 1, the second is 2, and so on. You must specify a valid substitution string number, that is, you can't specify a 4 if there are only three substitution strings. |
String |
Specify the text of the substitution string. |
Returns
None.
Syntax
ToString([AddContext])
Description
The ToString method returns the expanded message text associated with the exception in the current user's current language. The string returned is the message text (in the current user's language) with the substitution string replacing the substitution markers (%1 and so on) in the text. It always returns the context information about where the error occurred at the end of the message. To suppress this, specify AddContext as false.
Parameters
Field or Control |
Definition |
---|---|
AddContext |
Specify whether to have the context information about where the error occurred added at the end of the message. This parameter takes a Boolean value. The default is true, that is, to add the context information. |
Returns
A string.