mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 05:47:10 -04:00
10 lines
177 B
TypeScript
10 lines
177 B
TypeScript
![]() |
export { withDefaultOnError };
|
||
|
|
||
|
function withDefaultOnError<A, B>(cb: () => A, defaultValue: B): A | B {
|
||
|
try {
|
||
|
return cb();
|
||
|
} catch (_) {
|
||
|
return defaultValue;
|
||
|
}
|
||
|
}
|