aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-03-20 20:07:37 +0000
committers-ol <s-ol@users.noreply.github.com>2020-03-20 20:08:25 +0000
commit04eb8afc8367e51c15c507740b2c55fce2569b0d (patch)
tree01c5a53fbcd72d9a05009792126af5c54c8486ae /lib
parentdocs/index: mention license + repo (diff)
downloadalive-04eb8afc8367e51c15c507740b2c55fce2569b0d.tar.gz
alive-04eb8afc8367e51c15c507740b2c55fce2569b0d.zip
language Error tracking
Close #3
Diffstat (limited to 'lib')
-rw-r--r--lib/logic.moon4
-rw-r--r--lib/math.moon6
-rw-r--r--lib/midi/core.moon4
-rw-r--r--lib/pilot.moon6
-rw-r--r--lib/sc.moon8
-rw-r--r--lib/util.moon7
6 files changed, 18 insertions, 17 deletions
diff --git a/lib/logic.moon b/lib/logic.moon
index 7cf8695..7264be0 100644
--- a/lib/logic.moon
+++ b/lib/logic.moon
@@ -1,4 +1,4 @@
-import Op, Input, match from require 'core.base'
+import Op, Input, Error, match from require 'core.base'
all_same = (first, list) ->
for v in *list
@@ -72,7 +72,7 @@ class not_eq extends Op
new: => super 'bool'
setup: (inputs) =>
- assert #inputs > 1, "neq need at least two values"
+ assert #inputs > 1, Error 'argument', "need at least two values"
super [Input.value v for v in *inputs]
tick: =>
diff --git a/lib/math.moon b/lib/math.moon
index 02ba1e1..84e6682 100644
--- a/lib/math.moon
+++ b/lib/math.moon
@@ -1,4 +1,4 @@
-import Op, Value, Input, match from require 'core.base'
+import Op, Value, Error, Input, match from require 'core.base'
unpack or= table.unpack
class ReduceOp extends Op
@@ -71,7 +71,9 @@ func_op = (name, arity, func) ->
setup: (inputs) =>
{ params } = match '*num', inputs
- assert #params == arity, "#{@} needs exactly #{arity} parameters" if arity != '*'
+ if arity != '*'
+ err = Error 'argument', "need exactly #{arity} arguments"
+ assert #params == arity, err
super [Input.value p for p in *params]
tick: => @out\set func unpack @unwrap_all!
diff --git a/lib/midi/core.moon b/lib/midi/core.moon
index 8378b1d..75defdf 100644
--- a/lib/midi/core.moon
+++ b/lib/midi/core.moon
@@ -1,4 +1,4 @@
-import IO, Op, Registry, Input, match from require 'core.base'
+import IO, Op, Registry, Input, Error, match from require 'core.base'
import RtMidiIn, RtMidiOut, RtMidi from require 'luartmidi'
import band, bor, lshift, rshift from require 'bit32'
@@ -49,7 +49,7 @@ class MidiPort extends IO
coroutine.yield msg
send: (status, chan, a, b) =>
- assert @out, "#{@} is not an output or bidirectional port"
+ assert @out, Error 'type', "#{@} is not an output or bidirectional port"
if 'string' == type 'status'
status = bor (lshift rMIDI[status], 4), chan
@out\sendmessage status, a, b
diff --git a/lib/pilot.moon b/lib/pilot.moon
index f24270e..a687e48 100644
--- a/lib/pilot.moon
+++ b/lib/pilot.moon
@@ -1,4 +1,4 @@
-import Op, Input, match from require 'core.base'
+import Op, Input, Error, match from require 'core.base'
import udp from require 'socket'
local conn
@@ -25,7 +25,7 @@ class play extends Op
setup: (inputs) =>
{ trig, args } = match 'bang *any', inputs
- assert #args < 6, "too many arguments!"
+ assert #args < 6, Error 'argument', "too many arguments!"
super
trig: Input.event trig
args: [Input.cold a for a in *args]
@@ -40,7 +40,7 @@ class play_ extends Op
setup: (inputs) =>
{ chan, octv, note, args } = match 'any any any *any', inputs
- assert #args < 3, "too many arguments!"
+ assert #args < 3, Error 'argument', "too many arguments!"
super
chan: Input.cold chan
octv: Input.cold octv
diff --git a/lib/sc.moon b/lib/sc.moon
index ebdcd3b..7562620 100644
--- a/lib/sc.moon
+++ b/lib/sc.moon
@@ -1,4 +1,4 @@
-import Op, Input, match from require 'core.base'
+import Op, Input, Error, match from require 'core.base'
import pack from require 'osc'
import dns, udp from require 'socket'
@@ -8,11 +8,11 @@ class play extends Op
setup: (inputs) =>
{ socket, synth, trig, ctrls } = match 'udp/socket str bang *any?', inputs
- assert #ctrls % 2 == 0, "parameters need to be specified as pairs"
+ assert #ctrls % 2 == 0, Error 'argument', "parameters need to be specified as pairs"
for key in *ctrls[1,,2]
- assert key\type! == 'str', "ony strings are supported as control names"
+ assert key\type! == 'str', Error 'argument', "ony strings are supported as control names"
for val in *ctrls[2,,2]
- assert val\type! == 'num', "only numbers are supported as control values"
+ assert val\type! == 'num', Error 'argument', "only numbers are supported as control values"
super
trig: Input.event trig
diff --git a/lib/util.moon b/lib/util.moon
index 1fddca4..f816eee 100644
--- a/lib/util.moon
+++ b/lib/util.moon
@@ -1,5 +1,4 @@
-import Op, Value, Input, match
- from require 'core.base'
+import Op, Value, Input, Error, match from require 'core.base'
all_same = (list) ->
for v in *list[2,]
@@ -19,7 +18,7 @@ when i is a num, it is (floor)ed and the matching argument (starting from 0) is
{ i, values } = match 'any *any', inputs
i_type = i\type!
- assert i_type == 'bool' or i_type == 'num', "#{@}: i has to be bool or num"
+ assert i_type == 'bool' or i_type == 'num', Error 'argument', "i has to be bool or num"
typ = all_same [v\type! for v in *values]
@out = Value typ if not @out or typ != @out.type
@@ -50,7 +49,7 @@ when i is a num, it is (floor)ed and the matching argument (starting from 0) is
{ i, values } = match 'any *any', inputs
i_type = i\type!
- assert i_type == 'bool' or i_type == 'num', "#{@}: i has to be bool or num"
+ assert i_type == 'bool' or i_type == 'num', Error 'argument', "i has to be bool or num"
typ = all_same [v\type! for v in *values]
@out = Value typ if not @out or typ != @out.type