safeCallback
Exécute un callback dans un bloc sécurisé. Si le callback lève une erreur, la fonction renvoie un EitherLeft typé "callback" au lieu de propager l'exception.
Exemple interactif
Syntaxe
typescript
function safeCallback<GenericOutput extends unknown>(
theFunction: () => GenericOutput
): GenericOutput | EitherCallbackError;Paramètres
theFunction: Callback à exécuter en mode sécurisé.
Valeur de retour
- Si le callback réussit : la valeur retournée par
theFunction. - Si le callback lève une erreur :
EitherCallbackError(alias deleft("callback", error)).
Voir aussi
left– Construire unLefttypé.whenHasInformation– Pattern matching sur"callback".
