Skip to main content

Hi All,

 

We are using tableau js api to embed dashboards. There are a few cases when we see error popups like "Unknown server error" An unexpected error occurred. If you continue to receive this error please contact your Tableau Server Administrator.

 

I am trying to catch such errors and display some notice to the users but the onFirstInteractive event is not getting triggered and nor the try / catch block is working.

 

    try{

      frameDiv = jQuery("[data-tableau-frame]");

      let url = frameDiv.data("tableau-url");

      if (frameDiv.length > 0) {

        tableauViz = new tableau.Viz(frameDiv[0], url, {

          highdpi: true,

          onFirstInteractive: function(){

            console.log('hello world!');

            tableauViz.addEventListener(tableau.TableauEventName.FILTER_CHANGE, onFilterChange);

            tableauViz.addEventListener(tableau.TableauEventName.MARKS_SELECTION, onMarksSelection);

          }

        });

      }

    } catch(e) {

      console.log('here is the exception object');

      console.log(e);

      console.log('here is the exception object');

    }

 

I have also checked the documentation but could not find anything in this regard, may be i am missing something. Any help in this would be really great.

 

Thanks.

8 个回答
  1. 2021年4月19日 17:07

    Sure thing.

    const receiveMessage = (e: MessageEvent) => {

    const data = e.data;

    if (typeof data === "string" && data === "tableau.completed") {

    // handle appropriately

    };

     

    window.addEventListener("message", receiveMessage, false);

    I noticed that if an error occured when trying to load the viz, that "tableau.completed" was the data received and no further tableau messages occured.

    I check for the type to be of type string as some messages data property is an object and explicitly check for "tableau.completed" as

    I also noticed that "tableau.completed,-1,host0" is the message data when a viz is successfully rendered.

0/9000