ftos.context.response.getExceptionMessage
Extracts the exception message from a thrown error while ensuring cross-engine compatibility between different JavaScript runtimes such as Jint, JintV3, and V8.
Syntax
Copy
ftos.context.response.getExceptionMessage(exception: any): string
| Parameter | Description |
|---|---|
exception
|
The thrown exception object from which to extract the message. |
Return Value
Returns the extracted error message as a string.
Example
This example:
- Extracts error messages from both a standard JavaScript
Errorobject and a custom exception. - Uses the ftos.logging.log method to save the extracted messages in the system logs.
Copy
try {
// Example 1: Standard error
throw new Error("Invalid configuration detected");
} catch (ex) {
ftos.logging.log(ftos.context.response.getExceptionMessage(ex));
}
try {
// Example 2: Non-standard error object
throwException('Custom runtime failure');
} catch (ex) {
ftos.logging.log(ftos.context.response.getExceptionMessage(ex));
}