Throw errors instead of strings. (#1974)

Blocks and generators
This commit is contained in:
Neil Fraser
2018-07-16 16:33:44 -07:00
committed by GitHub
parent 99ebefa1bf
commit c8bfc888c8
23 changed files with 55 additions and 55 deletions

View File

@@ -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];

View File

@@ -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.');
};

View File

@@ -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];
};

View File

@@ -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];