Always ground your exposed callbacks
Always ground the callbacks that your API is exposing. If the consumer throws an exception, it will bubble up to your stack preventing further execution.
// ground callback exceptions
try{callback(true);}catch(ex){}
// ... or this part will never be reached
defer.resolve(true);Written by Thanasis Polychronakis
Related protips
1 Response
Food for thoughts:
http://jsperf.com/catched-callback
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Promises
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#