mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Add better error messages to insertion marker (#4791)
This commit is contained in:
@@ -148,6 +148,17 @@ Blockly.InsertionMarkerManager.PREVIEW_TYPE = {
|
||||
REPLACEMENT_FADE: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* An error message to throw if the block created by createMarkerBlock_ is
|
||||
* missing any components.
|
||||
* @type {string}
|
||||
* @const
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.DUPLICATE_BLOCK_ERROR = 'The insertion marker ' +
|
||||
'manager tried to create a marker but the result is missing %1. If ' +
|
||||
'you are using a mutator, make sure your domToMutation method is ' +
|
||||
'properly defined.';
|
||||
|
||||
/**
|
||||
* Sever all links from this object.
|
||||
* @package
|
||||
@@ -279,9 +290,17 @@ Blockly.InsertionMarkerManager.prototype.createMarkerBlock_ = function(sourceBlo
|
||||
continue; // Ignore the collapsed input.
|
||||
}
|
||||
var resultInput = result.inputList[i];
|
||||
if (!resultInput) {
|
||||
throw new Error(Blockly.InsertionMarkerManager.DUPLICATE_BLOCK_ERROR
|
||||
.replace('%1', 'an input'));
|
||||
}
|
||||
for (var j = 0; j < sourceInput.fieldRow.length; j++) {
|
||||
var sourceField = sourceInput.fieldRow[j];
|
||||
var resultField = resultInput.fieldRow[j];
|
||||
if (!resultField) {
|
||||
throw new Error(Blockly.InsertionMarkerManager.DUPLICATE_BLOCK_ERROR
|
||||
.replace('%1', 'a field'));
|
||||
}
|
||||
resultField.setValue(sourceField.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user