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

@@ -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);
});
},
/**

View File

@@ -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();

View File

@@ -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_) {