You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @rogierschouten! Thanks for keeping to work on this library, really appreciate 🙏
Correct me if I'm wrong, currently the only way to distinguish between async-lock errors and any error that's thrown by the wrapped async function is by using the error message:
IMHO it would be great if async-lock could deal with its own error classes to model anything can go wrong on the library side.
classAsyncLockErrorextendsError{constructor(message){super(message);}}classAsyncLockTimeoutErrorextendsAsyncLockError{constructor(queueKey){super(`Async lock timeout out in queue ${async-locktimedoutinqueue}`);this.name='AsyncLockTimeoutError';}}
This mean on the user-land side it would be much cleaner handling any async-lock error:
functionsomeAsyncFn(){}lock.acquire(key,someAsyncFn,opts)// Handle different kind of async-lock errors.catch(function(err){if(errinstanceofAsyncLockTimeoutError){// do something...}if(errinstanceofAsyncLockMaxOccTimeError){// do something...}});
functionsomeAsyncFn(){}lock.acquire(key,someAsyncFn,opts)// Catch any kind of async-lock errors.catch(function(err){if(errinstanceofAsyncLockError){// async-lock error}else{// Any error thrown by `someAsyncFn`}});
What do you think about that? I can find some time to work on this if it can help.
The text was updated successfully, but these errors were encountered:
Hi @rogierschouten! Thanks for keeping to work on this library, really appreciate 🙏
Correct me if I'm wrong, currently the only way to distinguish between async-lock errors and any error that's thrown by the wrapped async function is by using the error message:
IMHO it would be great if async-lock could deal with its own error classes to model anything can go wrong on the library side.
This mean on the user-land side it would be much cleaner handling any async-lock error:
What do you think about that? I can find some time to work on this if it can help.
The text was updated successfully, but these errors were encountered: