4 ms·
If you want to have a specific point to catch an exception, you could write something like this: def start_task(): thread = Thread(do_task)
by codedokode 9y ago
If you want to have a specific point to catch an exception, you could write something like this:
def start_task():
thread = Thread(do_task)
thread.set_error_handler(SpecificErrorType, handler)
thread.start()
- rictic 9y agoYes, but this has a natural analogue in promise land: function startTask() { const promise = doTask(); promise.catch((e) => { if (e instanceof SpecificErrorType) { handler(e); } else { throw e; } }); }
- codedokode 9y agoThe difference is the default behaviour: whether errors are fatal or whether they are ignored by default.