« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/common-util/sugar.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common-util/sugar.js b/src/common-util/sugar.js
index 26f33c20..67083293 100644
--- a/src/common-util/sugar.js
+++ b/src/common-util/sugar.js
@@ -441,6 +441,15 @@ export function promiseWithResolvers() {
   return obj;
 }
 
+export function errors(fn) {
+  try {
+    fn();
+    return false;
+  } catch {
+    return true;
+  }
+}
+
 // Stolen from here: https://stackoverflow.com/a/3561711
 //
 // There's a proposal for a native JS function like this, 8ut it's not even