diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 3a87fec128d3..652e5d613c59 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -291,8 +291,7 @@ var HotcueButton = function(options) { if (options.number === undefined) { - print("ERROR: No hotcue number specified for new HotcueButton."); - return; + throw Error("No hotcue number specified for new HotcueButton."); } if (options.colorMapper !== undefined || options.sendRGB !== undefined) { this.colorKey = "hotcue_" + options.number + "_color"; @@ -334,18 +333,18 @@ // get the MIDI value for the nearest supported color and send it. var nearestColorValue = this.colorMapper.getValueForNearestColor(colorCode); this.send(nearestColorValue); - } else { + } else if (this.sendRGB !== undefined) { // Since outputColor has been called but no ColorMapper is // available, we can assume that controller supports arbitrary // RGB color output. this.sendRGB(colorCodeToObject(colorCode)); + } else { + throw Error( + "HotcueButton is unable to send RGB color: colorKey has " + + "been set, but no color mapper was specified and the " + + "sendRGB(colorObject) method is not implemented!"); } }, - sendRGB: function(_colorObject) { - // This method needs to be overridden in controller mappings, - // because the procedure is controller-dependent. - throw Error("sendRGB(colorObject) not implemented - unable to send RGB colors!"); - }, connect: function() { Button.prototype.connect.call(this); // call parent connect if (undefined !== this.group && this.colorKey !== undefined) { @@ -359,8 +358,7 @@ }); var SamplerButton = function(options) { if (options.number === undefined) { - print("ERROR: No sampler number specified for new SamplerButton."); - return; + throw Error("No sampler number specified for new SamplerButton."); } this.volumeByVelocity = options.volumeByVelocity; this.number = options.number; @@ -509,8 +507,7 @@ ComponentContainer.prototype = { forEachComponent: function(operation, recursive) { if (typeof operation !== "function") { - print("ERROR: ComponentContainer.forEachComponent requires a function argument"); - return; + throw Error("ComponentContainer.forEachComponent requires a function argument"); } if (recursive === undefined) { recursive = true; } @@ -535,8 +532,7 @@ }, forEachComponentContainer: function(operation, recursive) { if (typeof operation !== "function") { - print("ERROR: ComponentContainer.forEachComponentContainer requires a function argument"); - return; + throw Error("ComponentContainer.forEachComponentContainer requires a function argument"); } if (recursive === undefined) { recursive = true; } @@ -677,8 +673,7 @@ this.deckNumbers = [deckNumbers]; } } else { - print("ERROR! new Deck() called without specifying any deck numbers"); - return; + throw Error("new Deck() called without specifying any deck numbers"); } }; Deck.prototype = new ComponentContainer({ @@ -827,8 +822,7 @@ this.setCurrentUnit(unitNumbers); } } else { - print("ERROR! new EffectUnit() called without specifying any unit numbers!"); - return; + throw Error("new EffectUnit() called without specifying any unit numbers!"); } this.dryWetKnob = new Pot({