This puts the errors as a list into a global variable called (errorLog) if its a list, otherwise it throws an error.
log types: process a snapshot, script the error throwing block, text error name, text message
script
// ==UserScript==
// @name Snap! debug
// @namespace none
// @version 2026-08-23-4
// @description helps debug Snap! projects, just define errorLog globally
// @author You
// @match https://snap.berkeley.edu/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=berkeley.edu
// @grant none
// ==/UserScript==
if(!Process) return; // only do Snap!
Process.prototype.throwError = function (error, element) {
var m = element,
ide = this.homeContext.receiver.parentThatIsA(IDE_Morph);
try{
let block = this.reportEnvironment(["script"]);
block.expression = this.context.expression;
world.childThatIsA(IDE_Morph).stage.variables.getVar('errorLog')
?.add?.(new List([copy(this),block,error.name,error.message]));
}catch(error){
return ide.showMessage("cannot log error because you need to define errorLog globally and set it to a list")
}
this.stop();
this.errorFlag = true;
this.topBlock.addErrorHighlight();
if (ide.isAppMode) {
ide.showMessage(localize(error.name) + '\n' + error.message);
} else {
if (isNil(m) || isNil(m.world())) {m = this.topBlock; }
m.showBubble(
this.errorBubble(error, element),
this.exportResult,
this.receiver
);
}
};
Process.prototype.resetErrorHandling()