diff --git a/blocks/lists.js b/blocks/lists.js index b8d91c56a..79cae676f 100644 --- a/blocks/lists.js +++ b/blocks/lists.js @@ -819,7 +819,7 @@ Blockly.Blocks['lists_split'] = { } else if (mode == 'JOIN') { return Blockly.Msg['LISTS_SPLIT_TOOLTIP_JOIN']; } - throw 'Unknown mode: ' + mode; + throw Error('Unknown mode: ' + mode); }); }, /** diff --git a/blocks/logic.js b/blocks/logic.js index 0d8f72111..01f4e55b6 100644 --- a/blocks/logic.js +++ b/blocks/logic.js @@ -381,7 +381,7 @@ Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN = { elseStatementConnection = clauseBlock.statementConnection_; break; default: - throw 'Unknown block type.'; + throw TypeError('Unknown block type: ' + clauseBlock.type); } clauseBlock = clauseBlock.nextConnection && clauseBlock.nextConnection.targetBlock(); @@ -419,7 +419,7 @@ Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN = { inputDo && inputDo.connection.targetConnection; break; default: - throw 'Unknown block type.'; + throw TypeError('Unknown block type: ' + clauseBlock.type); } clauseBlock = clauseBlock.nextConnection && clauseBlock.nextConnection.targetBlock(); diff --git a/blocks/procedures.js b/blocks/procedures.js index 7241dcf50..562bde00f 100644 --- a/blocks/procedures.js +++ b/blocks/procedures.js @@ -627,7 +627,7 @@ Blockly.Blocks['procedures_callnoreturn'] = { return; } if (paramIds.length != paramNames.length) { - throw 'Error: paramNames and paramIds must be the same length.'; + throw RangeError('paramNames and paramIds must be the same length.'); } this.setCollapsed(false); if (!this.quarkIds_) { diff --git a/generators/dart/lists.js b/generators/dart/lists.js index 42552713c..dd2a493e4 100644 --- a/generators/dart/lists.js +++ b/generators/dart/lists.js @@ -243,7 +243,7 @@ Blockly.Dart['lists_getIndex'] = function(block) { break; } } - throw 'Unhandled combination (lists_getIndex).'; + throw Error('Unhandled combination (lists_getIndex).'); }; Blockly.Dart['lists_setIndex'] = function(block) { @@ -323,7 +323,7 @@ Blockly.Dart['lists_setIndex'] = function(block) { } break; } - throw 'Unhandled combination (lists_setIndex).'; + throw Error('Unhandled combination (lists_setIndex).'); }; Blockly.Dart['lists_getSublist'] = function(block) { @@ -348,7 +348,7 @@ Blockly.Dart['lists_getSublist'] = function(block) { var at1 = '0'; break; default: - throw 'Unhandled option (lists_getSublist).'; + throw Error('Unhandled option (lists_getSublist).'); } switch (where2) { case 'FROM_START': @@ -363,7 +363,7 @@ Blockly.Dart['lists_getSublist'] = function(block) { // There is no second index if LAST option is chosen. break; default: - throw 'Unhandled option (lists_getSublist).'; + throw Error('Unhandled option (lists_getSublist).'); } if (where2 == 'LAST') { var code = list + '.sublist(' + at1 + ')'; @@ -445,7 +445,7 @@ Blockly.Dart['lists_split'] = function(block) { } var functionName = 'join'; } else { - throw 'Unknown mode: ' + mode; + throw Error('Unknown mode: ' + mode); } var code = input + '.' + functionName + '(' + delimiter + ')'; return [code, Blockly.Dart.ORDER_UNARY_POSTFIX]; diff --git a/generators/dart/loops.js b/generators/dart/loops.js index 0dd7c0ce5..6c83a2fd5 100644 --- a/generators/dart/loops.js +++ b/generators/dart/loops.js @@ -159,5 +159,5 @@ Blockly.Dart['controls_flow_statements'] = function(block) { case 'CONTINUE': return 'continue;\n'; } - throw 'Unknown flow statement.'; + throw Error('Unknown flow statement.'); }; diff --git a/generators/dart/math.js b/generators/dart/math.js index 867822beb..c37df0ea3 100644 --- a/generators/dart/math.js +++ b/generators/dart/math.js @@ -160,7 +160,7 @@ Blockly.Dart['math_single'] = function(block) { code = 'Math.atan(' + arg + ') / Math.PI * 180'; break; default: - throw 'Unknown math operator: ' + operator; + throw Error('Unknown math operator: ' + operator); } return [code, Blockly.Dart.ORDER_MULTIPLICATIVE]; }; @@ -426,7 +426,7 @@ Blockly.Dart['math_on_list'] = function(block) { code = functionName + '(' + list + ')'; break; default: - throw 'Unknown operator: ' + func; + throw Error('Unknown operator: ' + func); } return [code, Blockly.Dart.ORDER_UNARY_POSTFIX]; }; diff --git a/generators/dart/text.js b/generators/dart/text.js index 94c60f74b..589b1093b 100644 --- a/generators/dart/text.js +++ b/generators/dart/text.js @@ -136,7 +136,7 @@ Blockly.Dart['text_charAt'] = function(block) { code = functionName + '(' + text + ')'; return [code, Blockly.Dart.ORDER_UNARY_POSTFIX]; } - throw 'Unhandled option (text_charAt).'; + throw Error('Unhandled option (text_charAt).'); }; Blockly.Dart['text_getSubstring'] = function(block) { @@ -164,7 +164,7 @@ Blockly.Dart['text_getSubstring'] = function(block) { var at1 = '0'; break; default: - throw 'Unhandled option (text_getSubstring).'; + throw Error('Unhandled option (text_getSubstring).'); } switch (where2) { case 'FROM_START': @@ -178,7 +178,7 @@ Blockly.Dart['text_getSubstring'] = function(block) { case 'LAST': break; default: - throw 'Unhandled option (text_getSubstring).'; + throw Error('Unhandled option (text_getSubstring).'); } if (where2 == 'LAST') { var code = text + '.substring(' + at1 + ')'; diff --git a/generators/javascript/lists.js b/generators/javascript/lists.js index d9075953f..8ab563503 100644 --- a/generators/javascript/lists.js +++ b/generators/javascript/lists.js @@ -170,7 +170,7 @@ Blockly.JavaScript['lists_getIndex'] = function(block) { } break; } - throw 'Unhandled combination (lists_getIndex).'; + throw Error('Unhandled combination (lists_getIndex).'); }; Blockly.JavaScript['lists_setIndex'] = function(block) { @@ -247,7 +247,7 @@ Blockly.JavaScript['lists_setIndex'] = function(block) { } break; } - throw 'Unhandled combination (lists_setIndex).'; + throw Error('Unhandled combination (lists_setIndex).'); }; /** @@ -295,7 +295,7 @@ Blockly.JavaScript['lists_getSublist'] = function(block) { var at1 = '0'; break; default: - throw 'Unhandled option (lists_getSublist).'; + throw Error('Unhandled option (lists_getSublist).'); } switch (where2) { case 'FROM_START': @@ -310,7 +310,7 @@ Blockly.JavaScript['lists_getSublist'] = function(block) { var at2 = list + '.length'; break; default: - throw 'Unhandled option (lists_getSublist).'; + throw Error('Unhandled option (lists_getSublist).'); } code = list + '.slice(' + at1 + ', ' + at2 + ')'; } else { @@ -387,7 +387,7 @@ Blockly.JavaScript['lists_split'] = function(block) { } var functionName = 'join'; } else { - throw 'Unknown mode: ' + mode; + throw Error('Unknown mode: ' + mode); } var code = input + '.' + functionName + '(' + delimiter + ')'; return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL]; diff --git a/generators/javascript/loops.js b/generators/javascript/loops.js index 1a2ade593..416bbc8be 100644 --- a/generators/javascript/loops.js +++ b/generators/javascript/loops.js @@ -171,5 +171,5 @@ Blockly.JavaScript['controls_flow_statements'] = function(block) { case 'CONTINUE': return 'continue;\n'; } - throw 'Unknown flow statement.'; + throw Error('Unknown flow statement.'); }; diff --git a/generators/javascript/math.js b/generators/javascript/math.js index 0bd265af2..191e7af1e 100644 --- a/generators/javascript/math.js +++ b/generators/javascript/math.js @@ -32,7 +32,7 @@ goog.require('Blockly.JavaScript'); Blockly.JavaScript['math_number'] = function(block) { // Numeric value. var code = parseFloat(block.getFieldValue('NUM')); - var order = code >= 0 ? Blockly.JavaScript.ORDER_ATOMIC : + var order = code >= 0 ? Blockly.JavaScript.ORDER_ATOMIC : Blockly.JavaScript.ORDER_UNARY_NEGATION; return [code, order]; }; @@ -140,7 +140,7 @@ Blockly.JavaScript['math_single'] = function(block) { code = 'Math.atan(' + arg + ') / Math.PI * 180'; break; default: - throw 'Unknown math operator: ' + operator; + throw Error('Unknown math operator: ' + operator); } return [code, Blockly.JavaScript.ORDER_DIVISION]; }; @@ -357,7 +357,7 @@ Blockly.JavaScript['math_on_list'] = function(block) { code = functionName + '(' + list + ')'; break; default: - throw 'Unknown operator: ' + func; + throw Error('Unknown operator: ' + func); } return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL]; }; diff --git a/generators/javascript/text.js b/generators/javascript/text.js index 9e2a375a2..357ca3eb9 100644 --- a/generators/javascript/text.js +++ b/generators/javascript/text.js @@ -137,7 +137,7 @@ Blockly.JavaScript['text_charAt'] = function(block) { var code = functionName + '(' + text + ')'; return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL]; } - throw 'Unhandled option (text_charAt).'; + throw Error('Unhandled option (text_charAt).'); }; /** @@ -186,7 +186,7 @@ Blockly.JavaScript['text_getSubstring'] = function(block) { var at1 = '0'; break; default: - throw 'Unhandled option (text_getSubstring).'; + throw Error('Unhandled option (text_getSubstring).'); } switch (where2) { case 'FROM_START': @@ -201,7 +201,7 @@ Blockly.JavaScript['text_getSubstring'] = function(block) { var at2 = text + '.length'; break; default: - throw 'Unhandled option (text_getSubstring).'; + throw Error('Unhandled option (text_getSubstring).'); } code = text + '.slice(' + at1 + ', ' + at2 + ')'; } else { diff --git a/generators/lua/lists.js b/generators/lua/lists.js index 6b9fe006e..bdb89baf6 100644 --- a/generators/lua/lists.js +++ b/generators/lua/lists.js @@ -358,7 +358,7 @@ Blockly.Lua['lists_split'] = function(block) { } functionName = 'table.concat'; } else { - throw 'Unknown mode: ' + mode; + throw Error('Unknown mode: ' + mode); } var code = functionName + '(' + input + ', ' + delimiter + ')'; return [code, Blockly.Lua.ORDER_HIGH]; diff --git a/generators/lua/loops.js b/generators/lua/loops.js index 785398ff7..d671534a6 100644 --- a/generators/lua/loops.js +++ b/generators/lua/loops.js @@ -162,5 +162,5 @@ Blockly.Lua['controls_flow_statements'] = function(block) { case 'CONTINUE': return Blockly.Lua.CONTINUE_STATEMENT; } - throw 'Unknown flow statement.'; + throw Error('Unknown flow statement.'); }; diff --git a/generators/lua/math.js b/generators/lua/math.js index b60d023da..eefcee4ae 100644 --- a/generators/lua/math.js +++ b/generators/lua/math.js @@ -123,7 +123,7 @@ Blockly.Lua['math_single'] = function(block) { code = 'math.deg(math.atan(' + arg + '))'; break; default: - throw 'Unknown math operator: ' + operator; + throw Error('Unknown math operator: ' + operator); } return [code, Blockly.Lua.ORDER_HIGH]; }; @@ -383,7 +383,7 @@ Blockly.Lua['math_on_list'] = function(block) { break; default: - throw 'Unknown operator: ' + func; + throw Error('Unknown operator: ' + func); } return [functionName + '(' + list + ')', Blockly.Lua.ORDER_HIGH]; }; diff --git a/generators/lua/text.js b/generators/lua/text.js index 8a2ac914a..8f6c9467e 100644 --- a/generators/lua/text.js +++ b/generators/lua/text.js @@ -149,7 +149,7 @@ Blockly.Lua['text_charAt'] = function(block) { } else if (where == 'FROM_END') { var start = '-' + at; } else { - throw 'Unhandled option (text_charAt).'; + throw Error('Unhandled option (text_charAt).'); } } if (start.match(/^-?\w*$/)) { @@ -185,7 +185,7 @@ Blockly.Lua['text_getSubstring'] = function(block) { } else if (where1 == 'FROM_END') { var start = '-' + at1; } else { - throw 'Unhandled option (text_getSubstring)'; + throw Error('Unhandled option (text_getSubstring)'); } // Get end index. @@ -200,7 +200,7 @@ Blockly.Lua['text_getSubstring'] = function(block) { } else if (where2 == 'FROM_END') { var end = '-' + at2; } else { - throw 'Unhandled option (text_getSubstring)'; + throw Error('Unhandled option (text_getSubstring)'); } var code = 'string.sub(' + text + ', ' + start + ', ' + end + ')'; return [code, Blockly.Lua.ORDER_HIGH]; diff --git a/generators/php/lists.js b/generators/php/lists.js index 3fd261695..47262d6a5 100644 --- a/generators/php/lists.js +++ b/generators/php/lists.js @@ -255,7 +255,7 @@ Blockly.PHP['lists_getIndex'] = function(block) { } break; } - throw 'Unhandled combination (lists_getIndex).'; + throw Error('Unhandled combination (lists_getIndex).'); }; Blockly.PHP['lists_setIndex'] = function(block) { @@ -355,7 +355,7 @@ Blockly.PHP['lists_setIndex'] = function(block) { } break; } - throw 'Unhandled combination (lists_setIndex).'; + throw Error('Unhandled combination (lists_setIndex).'); }; Blockly.PHP['lists_getSublist'] = function(block) { @@ -383,7 +383,7 @@ Blockly.PHP['lists_getSublist'] = function(block) { var at1 = '0'; break; default: - throw 'Unhandled option (lists_getSublist).'; + throw Error('Unhandled option (lists_getSublist).'); } switch (where2) { case 'FROM_START': @@ -416,7 +416,7 @@ Blockly.PHP['lists_getSublist'] = function(block) { } break; default: - throw 'Unhandled option (lists_getSublist).'; + throw Error('Unhandled option (lists_getSublist).'); } code = 'array_slice(' + list + ', ' + at1 + ', ' + length + ')'; } else { @@ -497,7 +497,7 @@ Blockly.PHP['lists_split'] = function(block) { } var functionName = 'implode'; } else { - throw 'Unknown mode: ' + mode; + throw Error('Unknown mode: ' + mode); } var code = functionName + '(' + value_delim + ', ' + value_input + ')'; return [code, Blockly.PHP.ORDER_FUNCTION_CALL]; diff --git a/generators/php/loops.js b/generators/php/loops.js index f306b1053..b504740ba 100644 --- a/generators/php/loops.js +++ b/generators/php/loops.js @@ -160,5 +160,5 @@ Blockly.PHP['controls_flow_statements'] = function(block) { case 'CONTINUE': return 'continue;\n'; } - throw 'Unknown flow statement.'; + throw Error('Unknown flow statement.'); }; diff --git a/generators/php/math.js b/generators/php/math.js index ef9419603..5100d0f4b 100644 --- a/generators/php/math.js +++ b/generators/php/math.js @@ -32,7 +32,7 @@ goog.require('Blockly.PHP'); Blockly.PHP['math_number'] = function(block) { // Numeric value. var code = parseFloat(block.getFieldValue('NUM')); - var order = code >= 0 ? Blockly.PHP.ORDER_ATOMIC : + var order = code >= 0 ? Blockly.PHP.ORDER_ATOMIC : Blockly.PHP.ORDER_UNARY_NEGATION; if (code == Infinity) { code = 'INF'; @@ -139,7 +139,7 @@ Blockly.PHP['math_single'] = function(block) { code = 'atan(' + arg + ') / pi() * 180'; break; default: - throw 'Unknown math operator: ' + operator; + throw Error('Unknown math operator: ' + operator); } return [code, Blockly.PHP.ORDER_DIVISION]; }; @@ -321,7 +321,7 @@ Blockly.PHP['math_on_list'] = function(block) { code = functionName + '(' + list + ')'; break; default: - throw 'Unknown operator: ' + func; + throw Error('Unknown operator: ' + func); } return [code, Blockly.PHP.ORDER_FUNCTION_CALL]; }; diff --git a/generators/php/text.js b/generators/php/text.js index 7903d31e7..4eeead148 100644 --- a/generators/php/text.js +++ b/generators/php/text.js @@ -152,7 +152,7 @@ Blockly.PHP['text_charAt'] = function(block) { code = functionName + '(' + text + ')'; return [code, Blockly.PHP.ORDER_FUNCTION_CALL]; } - throw 'Unhandled option (text_charAt).'; + throw Error('Unhandled option (text_charAt).'); }; Blockly.PHP['text_getSubstring'] = function(block) { diff --git a/generators/python/lists.js b/generators/python/lists.js index 3d29acf22..657e44d1d 100644 --- a/generators/python/lists.js +++ b/generators/python/lists.js @@ -183,7 +183,7 @@ Blockly.Python['lists_getIndex'] = function(block) { } break; } - throw 'Unhandled combination (lists_getIndex).'; + throw Error('Unhandled combination (lists_getIndex).'); }; Blockly.Python['lists_setIndex'] = function(block) { @@ -254,7 +254,7 @@ Blockly.Python['lists_setIndex'] = function(block) { } break; } - throw 'Unhandled combination (lists_setIndex).'; + throw Error('Unhandled combination (lists_setIndex).'); }; Blockly.Python['lists_getSublist'] = function(block) { @@ -277,7 +277,7 @@ Blockly.Python['lists_getSublist'] = function(block) { var at1 = ''; break; default: - throw 'Unhandled option (lists_getSublist)'; + throw Error('Unhandled option (lists_getSublist)'); } switch (where2) { case 'FROM_START': @@ -298,7 +298,7 @@ Blockly.Python['lists_getSublist'] = function(block) { var at2 = ''; break; default: - throw 'Unhandled option (lists_getSublist)'; + throw Error('Unhandled option (lists_getSublist)'); } var code = list + '[' + at1 + ' : ' + at2 + ']'; return [code, Blockly.Python.ORDER_MEMBER]; @@ -349,7 +349,7 @@ Blockly.Python['lists_split'] = function(block) { Blockly.Python.ORDER_MEMBER) || '\'\''; var code = value_delim + '.join(' + value_input + ')'; } else { - throw 'Unknown mode: ' + mode; + throw Error('Unknown mode: ' + mode); } return [code, Blockly.Python.ORDER_FUNCTION_CALL]; }; diff --git a/generators/python/loops.js b/generators/python/loops.js index 3cb1ab900..918bcdfb5 100644 --- a/generators/python/loops.js +++ b/generators/python/loops.js @@ -207,5 +207,5 @@ Blockly.Python['controls_flow_statements'] = function(block) { case 'CONTINUE': return 'continue\n'; } - throw 'Unknown flow statement.'; + throw Error('Unknown flow statement.'); }; diff --git a/generators/python/math.js b/generators/python/math.js index a2595e00c..f1307d71a 100644 --- a/generators/python/math.js +++ b/generators/python/math.js @@ -147,7 +147,7 @@ Blockly.Python['math_single'] = function(block) { code = 'math.atan(' + arg + ') / math.pi * 180'; break; default: - throw 'Unknown math operator: ' + operator; + throw Error('Unknown math operator: ' + operator); } return [code, Blockly.Python.ORDER_MULTIPLICATIVE]; }; @@ -342,7 +342,7 @@ Blockly.Python['math_on_list'] = function(block) { code = 'random.choice(' + list + ')'; break; default: - throw 'Unknown operator: ' + func; + throw Error('Unknown operator: ' + func); } return [code, Blockly.Python.ORDER_FUNCTION_CALL]; }; diff --git a/generators/python/text.js b/generators/python/text.js index 0fefc77d9..2ff767b14 100644 --- a/generators/python/text.js +++ b/generators/python/text.js @@ -140,7 +140,7 @@ Blockly.Python['text_charAt'] = function(block) { code = functionName + '(' + text + ')'; return [code, Blockly.Python.ORDER_FUNCTION_CALL]; } - throw 'Unhandled option (text_charAt).'; + throw Error('Unhandled option (text_charAt).'); }; Blockly.Python['text_getSubstring'] = function(block) { @@ -163,7 +163,7 @@ Blockly.Python['text_getSubstring'] = function(block) { var at1 = ''; break; default: - throw 'Unhandled option (text_getSubstring)'; + throw Error('Unhandled option (text_getSubstring)'); } switch (where2) { case 'FROM_START': @@ -184,7 +184,7 @@ Blockly.Python['text_getSubstring'] = function(block) { var at2 = ''; break; default: - throw 'Unhandled option (text_getSubstring)'; + throw Error('Unhandled option (text_getSubstring)'); } var code = text + '[' + at1 + ' : ' + at2 + ']'; return [code, Blockly.Python.ORDER_MEMBER];