I have understood that Promise is a special object in which javascript which helps us to deal with asynchronous tasks and catch errors which arise from it .
I am familiar with the below usage :
func_returning_promise( )
.then((param)=>{do stuff with the param ; }
.catch((error) =>{console.log(error); }
How ever I quite didn't like the .then and .catch used like this and so I stored the Promise in a variable var myprom = func_returning_promise()
.
But when I call the "then" and "catch" methods like this , the error doesn't get handled at all and doesn't execute the catch
handler.
var myprom = func_returning_promise();
myprom.then((param)=> do stuff with param ) ;
myprom.catch((error)=> console.log(error)) ;
Why I am still getting errored out and why itsn't the catch handler executing ?
Has it got anything to do with the semicolon ;
put at the end of then
method ?
This is not a duplicate of question Placement of catch before or after then
My question isn't about the placement of then and catch at all which the mentioned question addresses.