From 7e537fc7aec9fc1c25aedf20a786b6c60bcd1d69 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Tue, 6 Jul 2021 11:53:28 -0700 Subject: [PATCH] WIP show block calling a reportGetVar --- src/blocks.js | 11 ++++++++--- src/threads.js | 17 ++++------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/blocks.js b/src/blocks.js index 9d1532d6..4e566a4d 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -4196,13 +4196,18 @@ 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. - if (this.nextBlock) { - var copy = this.fullCopy(); + 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 this.fullImage(); + return block.fullImage(); } BlockMorph.prototype.fullImage = function () { diff --git a/src/threads.js b/src/threads.js index 00b7dc08..5947fce8 100644 --- a/src/threads.js +++ b/src/threads.js @@ -1176,9 +1176,9 @@ Process.prototype.errorBubble = function (error, element) { // above the text of error. var errorMorph = new AlignmentMorph('column', 5), errorIsNested = isNil(element.world()), - errorPrefix = errorIsNested ? localize('Inside a custom block') + ':\n' : '', + errorPrefix = errorIsNested ? `${localize('Inside a custom block')}:\n`: '', errorMessage = new TextMorph( - errorPrefix + localize(error.name) + ':\n' + error.message, + `${errorPrefix}${localize(error.name)}:\n${localize(error.message)}`, SyntaxElementMorph.prototype.fontSize ), img, blockImage; @@ -1186,22 +1186,13 @@ Process.prototype.errorBubble = function (error, element) { errorMorph.add(errorMessage); errorMorph.alpha = 0; if (errorIsNested) { - window.element = element; + errorMorph.text += `\n${localize('The error occured at:')}\n`; img = element.errorPic(); blockImage = new Morph(); blockImage.isCachingImage = true; - blockImage.bounds.setWidth(img.width); - blockImage.bounds.setHeight(img.height); - - // blockImage.setExtent(new Point(img.width, img.height)); + blockImage.setExtent(new Point(img.width, img.height)); blockImage.cachedImage = img; - // blockImage.image = img; - // errorMessage.setTop(blockImage.height() + 2); errorMorph.add(blockImage); - // errorMorph.setExtent(new Point( - // Math.max(blockImage.width(), errorMessage.width()), - // blockImage.height() + errorMessage.height() - // )); errorMorph.fixLayout(); }