kopia lustrzana https://github.com/backface/turtlestitch
Refactor: Show the block where an error occured in a custom block
rodzic
7e537fc7ae
commit
0c3cfe0d21
|
@ -4192,24 +4192,6 @@ BlockMorph.prototype.scriptPic = function () {
|
|||
return pic;
|
||||
};
|
||||
|
||||
BlockMorph.prototype.errorPic = function () {
|
||||
// return a picture of myself, that approximately fits in "one line"
|
||||
// filter any blocks beneath me, so that users only see the first
|
||||
// block that caused an error.
|
||||
var block = this;
|
||||
if (block.selector === 'reportGetVar') {
|
||||
// if I am a single variable, show my caller in the output.
|
||||
block = block.parent;
|
||||
}
|
||||
if (block.nextBlock) {
|
||||
var copy = block.fullCopy();
|
||||
copy.removeChild(copy.nextBlock());
|
||||
return copy.fullImage();
|
||||
}
|
||||
|
||||
return block.fullImage();
|
||||
}
|
||||
|
||||
BlockMorph.prototype.fullImage = function () {
|
||||
// answer a canvas image meant for (semi-) transparent blocks
|
||||
// that lets the background shine through
|
||||
|
|
|
@ -1181,18 +1181,16 @@ Process.prototype.errorBubble = function (error, element) {
|
|||
`${errorPrefix}${localize(error.name)}:\n${localize(error.message)}`,
|
||||
SyntaxElementMorph.prototype.fontSize
|
||||
),
|
||||
img, blockImage;
|
||||
blockToShow = element;
|
||||
|
||||
errorMorph.add(errorMessage);
|
||||
errorMorph.alpha = 0;
|
||||
if (errorIsNested) {
|
||||
if (blockToShow.selector === 'reportGetVar') {
|
||||
// if I am a single variable, show my caller in the output.
|
||||
blockToShow = blockToShow.parent;
|
||||
}
|
||||
errorMorph.text += `\n${localize('The error occured at:')}\n`;
|
||||
img = element.errorPic();
|
||||
blockImage = new Morph();
|
||||
blockImage.isCachingImage = true;
|
||||
blockImage.setExtent(new Point(img.width, img.height));
|
||||
blockImage.cachedImage = img;
|
||||
errorMorph.add(blockImage);
|
||||
errorMorph.add(blockToShow);
|
||||
errorMorph.fixLayout();
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue