Just Questions about Java Script
#2543
-
Hi!Why we are using |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hey @MasterofBlockchain we are using a promise here just to make sure we catch the event being emmitted. And to be clear, the try catch doesn't helps us in listening because if the listener doesn't catch the event, the |
Beta Was this translation helpful? Give feedback.
-
"listener has try Catch" In the try-catch, the try block has no functionality whatsoever, only the catch block is used, and serves to "catch" (also rejects for the promise) any error caught on evaluation. Additionally, even if the try block contained some logic, it is not inclusive of the listener. Therefore, the promise checks whether the listener itself resolves or rejects. Of course, you can also do a big try block but promises are more versatile. |
Beta Was this translation helpful? Give feedback.
"listener has try Catch" In the try-catch, the try block has no functionality whatsoever, only the catch block is used, and serves to "catch" (also rejects for the promise) any error caught on evaluation. Additionally, even if the try block contained some logic, it is not inclusive of the listener.
Therefore, the promise checks whether the listener itself resolves or rejects.
Of course, you can also do a big try block but promises are more versatile.