0

I have the following function returns a promise:

showObjects(data: ShowObjects[], parameters: ShowObjectsParameters): Promise<number> {
    if (data && data.length) return this.layerSearchManager.search(data, parameters);
}

Using is:

async show() {
   try {
     const id = await = this.showObjects([], {});
   } catch (e) {
      console.log(e);
   }
}

In case when

if (data && data.length)
is false. I should reject promise to catch error message in try/catch instead returning undefined. How to do that?

Anonymous Asked question May 13, 2021