« get me outta code hell

Throw errors when a bad sort/loop mode is given - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2017-08-11 19:40:31 -0300
committerFlorrie <towerofnix@gmail.com>2017-08-11 19:40:31 -0300
commit4222e4f96eef533cfd4357fe64743ba740ee4065 (patch)
tree9a818e05b9d8fc0a62adca8453f0a590dfffdb2f
parente61800db022691cb0024dd7690fa8823daaf8ede (diff)
Throw errors when a bad sort/loop mode is given
-rw-r--r--src/pickers.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/pickers.js b/src/pickers.js
index 190532c..f44a675 100644
--- a/src/pickers.js
+++ b/src/pickers.js
@@ -28,6 +28,20 @@ function makePicker(grouplike, sort, loop) {
   //
   // Both of those options could probably be handled via the 'loop' option.
 
+  if (![
+    'order', 'ordered', 'shuffle', 'shuffled', 'shuffle-groups',
+    'shuffled-groups'
+  ].includes(sort)) {
+    throw new Error(`Invalid sort mode: ${sort}`)
+  }
+
+  if (![
+    'loop', 'no-loop', 'no', 'loop-same-order', 'loop-regenerate',
+    'pick-random'
+  ].includes(loop)) {
+    throw new Error(`Invalid loop mode: ${loop}`)
+  }
+
   const topLevel = {items: []}
 
   let generateTopLevel = () => {