Reputation: 71
private async getData(): Promise<Array<DataSet>> {
// the next line returns an error
this.portalConf = await GetProcedure.exe(this.portalId ? this.portalId : PortalStore.getPortalId());
this.portal = new Portal(this.portalConf.name, this.portalConf.id, this.portalConf.content, '');
DataSet.resetStore();
return GetData.getDatasets(this.portal);
}
the "this.conf" line returns an error , how can I catch that error and act on it ?
Upvotes: 1
Views: 1482
Reputation: 308
You can use the below code: simply use try and catch blocks
private async getData(): Promise < Array < DataSet >> {
try {
// the next line returns an error
this.portalConf = await GetProcedure.exe(this.portalId ? this.portalId : PortalStore.getPortalId());
this.portal = new Portal(this.portalConf.name, this.portalConf.id, this.portalConf.content, '');
DataSet.resetStore();
return GetData.getDatasets(this.portal);
} catch (error) {
console.log('error', error);
}
}
Upvotes: 2