ThrowError
Last modified by Outhman Moustaghfir on 2025/03/21 11:29
Description
The ThrowError function is used to generate custom error messages in XSLT transformations. When triggered, it stops the execution and displays the error message provided by the user.
Syntax
<TEST><xsl:value-of select="ixf:ThrowError('Error message format', value1, value2, ...)"/></TEST>
- 'Error message format': A string that represents the error message. It can include placeholders (%1, %2, etc.) to insert variable values.
- value1, value2, ...: The values that replace the placeholders in the message.
Example Usages
1. Simple Error Message
This example throws a general error message:
<TEST><xsl:value-of select="ixf:ThrowError('An unexpected error occurred. Please try again.')"/></TEST>
💡 Output:
An unexpected error occurred. Please try again.
2. Error with Dynamic Values
If an error message requires dynamic values, placeholders (%1, %2, etc.) can be used:
<TEST><xsl:value-of select="ixf:ThrowError('Invalid input: %1. Expected: %2.', 'abc', 'number')"/></TEST>
💡 Output:
Invalid input: abc. Expected: number.
3. Missing Required Field
<TEST><xsl:value-of select="ixf:ThrowError('Missing required field: %1.', 'Username')"/></TEST>
💡 Output:
Missing required field: Username.
4. Access Denied Error
💡 Output:
Access denied. User JohnDoe does not have permission.
5. Operation Failure
💡 Output:
Operation failed. Error: Database connection lost.