I am using typescript and used promises to maintain synchronous behavior in my code .As per my research though we have try catch bloc around promise we are getting un-handled exception when something goes wrong in our promise
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): false
to overcome this issue I have added catch bloc to my promise as below. However I am not confident about best practice of this usage. If anyone can share advice on this it would be very helpful.
async testMethod(pram1 : pramType): Promise<boolean>{
try{
return await this.promisemethod(pram1).catch(function () {
tl.debug("Promise Rejected");
return false;});
}catch () {
tl.debug("Method Failed");
}
}