This Error Example

This example shows you how to catch errors that occur inside a macro and display the error.

Smartsite SXML CopyCode image Copy Code
<se:text>
    <se:parameters>
        <se:parameter name="value">
            {math.abs(1 / 0)}
        </se:parameter>
        <se:parameter name="error">
            Exception message = {this.error.message()}
            Exception code = {this.error.smartsitecode(default='There is no code for this exception.')}
            Exception type = {this.error.type()}
        </se:parameter>
    </se:parameters>
</se:text>
Example Result CopyCode image Copy Code
Exception message = Error setting the property 'value' on the macro 'text': Divide by zero error.
            Exception code = SCMS000000
            Exception type = Smartsite.Core.ExpressionException