cancel
Showing results for 
Search instead for 
Did you mean: 
Liliia_DevX
Sisense Team Member

How to access the error in the widget object from the script (Linux)

Introduction

This article provides guidance on extracting error messages from a widget object that might be used for logging in other systems.

Step-by-Step Guide

To extract and properly log error messages from a widget's object, follow these steps:

1. Understanding the Error Object: When extracting error states, it's important to recognize that the error content might be an object rather than a simple string. Directly throwing an object as an error can lead to null or empty string values.

2. Using Event Handlers: Utilize the widget's ready event to access the error object.

3. Processing Widgets Differently: Some widgets may not have their errors in the expected property. If a network failure occurs, the error might be located differently. Hence, stringify the entire w.$error object when necessary.

widget?.on("ready", (w) => {
  if (w.$error) {
    //Log the error in the console, or handle according to your needs
    console.error("Widget error:", w.$error);

    // Or throw the error
    throw new Error(JSON.stringify(w.$error));
  } else {
    console.log("No error. Widget loaded successfully");
  }
});

4. Using Error Details: For simplicity, you can directly access and log the error details:

if (w.$error) {
  // Log just the error details in the console, or handle according to your needs
  console.log("Error details:", JSON.stringify(w.$error.details));
}

Conclusion

To successfully capture and log widget error states, it is crucial to handle the error object appropriately. Stringifying the error provides a comprehensive error message. If you encounter further issues or need more assistance, consider exploring the developer documentation linked below.

References/ Related Content

Disclaimer: This post outlines a potential custom workaround for a specific use case or provides instructions regarding a specific task. The solution may not work in all scenarios or Sisense versions, so we strongly recommend testing it in your environment before deployment. If you need further assistance with this please let us know.

Version history
Last update:
‎05-08-2025 09:17 AM
Updated by:
Contributors