RevealBi / Reveal.Sdk

Issue tracker - Reveal SDK https://www.revealbi.io/
https://www.revealbi.io/
3 stars 0 forks source link

Allow custom defined error messages from the SDK #180

Open exscalliber opened 3 months ago

exscalliber commented 3 months ago

Hi, I notice that whenever there's an error from the server the Reveal SDK returns an object similar to "error: { message, errorCode }". I Would like to be able to return a custom error message on the client reveal if i encounter an error on the server that i cause through my own code.

Here is the an example client error message alert/popup that gets the error message from the server SDK:

object_error

In my particular use case i am doing an SQL query to do a preliminary check before i return a datasourceItem when creating a visualization. for example (using Node SDK):

const dataSourceItemProvider = async (userContext: IRVUserContext | null, dataSourceItem: RVDataSourceItem) => {
  if (dataSourceItem instanceof RVSqlServerDataSourceItem) {
    dataSourceProvider(userContext, dataSourceItem.dataSource);

    if (dataSourceItem.id === "MySqlServerDatasourceItem") {
      // custom code here that does stuff that may error
      // ideally id just do this:
      throw new Error("WHERE EXE?!");
    }
  }
  return dataSourceItem;
}

Right now the datasource will just display a generic error message. If i know what the error message could be it would be useful to return a more specific error message.