mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911)
This commit is contained in:
committed by
GitHub
parent
680fc4b6d3
commit
24ebbcaad0
@@ -1107,7 +1107,7 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
|
||||
}
|
||||
}
|
||||
goog.asserts.assert(indexCount == args.length,
|
||||
'Message does not reference all %s arg(s).', args.length);
|
||||
'block "%s": Message does not reference all %s arg(s).', this.type, args.length);
|
||||
// Add last dummy input if needed.
|
||||
if (elements.length && (typeof elements[elements.length - 1] == 'string' ||
|
||||
goog.string.startsWith(elements[elements.length - 1]['type'],
|
||||
@@ -1449,3 +1449,20 @@ Blockly.Block.prototype.allInputsFilled = function(opt_shadowBlocksAreFilled) {
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* This method returns a string describing this Block in developer terms (type
|
||||
* name and ID; English only).
|
||||
*
|
||||
* Intended to on be used in console logs and errors. If you need a string that
|
||||
* uses the user's native language (including block text, field values, and
|
||||
* child blocks), use [toString()]{@link Blockly.Block#toString}.
|
||||
* @return {string} The description.
|
||||
*/
|
||||
Blockly.Block.prototype.toDevString = function() {
|
||||
var msg = this.type ? '"' + this.type + '" block' : 'Block';
|
||||
if (this.id) {
|
||||
msg += ' (id="' + this.id + '")';
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user