« get me outta code hell

tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/util/exception.js
diff options
context:
space:
mode:
Diffstat (limited to 'util/exception.js')
-rw-r--r--util/exception.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/exception.js b/util/exception.js
new file mode 100644
index 0000000..e88ff99
--- /dev/null
+++ b/util/exception.js
@@ -0,0 +1,7 @@
+module.exports = function exception(code, message) {
+  // Makes a custom error with the given code and message.
+
+  const err = new Error(`${code}: ${message}`)
+  err.code = code
+  return err
+}