Skip to content

Commit

Permalink
customop errorhandling with new op class
Browse files Browse the repository at this point in the history
  • Loading branch information
steam0r committed Jan 17, 2025
1 parent 0eb439c commit ec20a85
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ const execute = () =>
const name = "Ops.Custom.CUSTOM" + op.id.replace(/-/g, "");
const code = inJS.get();
let codeHead = "Ops.Custom = Ops.Custom || {};\n";
codeHead += name + " = " + name + " || {};\n";
codeHead += name + " = function()\n{\nCABLES.Op.apply(this,arguments);\nconst op=this;\n";
let codeFoot = "\n\n};\n\n" + name + ".prototype = new CABLES.Op();\n";
codeHead += name + " = class extends CABLES.Op \n{";
codeHead += "constructor()\n{ super(...arguments);\nconst op=this;const attachments=op.attachments={};\n";
let codeFoot = "}\n\n};\n\n";
codeFoot += "new " + name + "();\n";
const opCode = codeHead + code + codeFoot;
op.setUiError("error", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
"type": "deprecation",
"author": "stephan",
"date": 1719915871534
},
{
"message": "refactor to use new op class",
"type": "improvement",
"author": "stephan",
"date": 1737112559414
}
],
"authorName": "stephan",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ op.onError = function (ex)
if (badLines[bj] == j) isBadLine = true;

if (isBadLine) htmlWarning += "<span class=\"error\">";
htmlWarning += line.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;")
htmlWarning += line.replaceAll("&", "&amp;").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", "&quot;")
.replaceAll("'", "&#039;");
if (isBadLine) htmlWarning += "</span>";
}
Expand Down Expand Up @@ -310,11 +310,12 @@ const execute = () =>
const name = "Ops.Custom.CUSTOM" + op.id.replace(/-/g, "");
const code = inJS.get();
let codeHead = "Ops.Custom = Ops.Custom || {};\n";
codeHead += name + " = " + name + " || {};\n";
codeHead += name + " = function()\n{\nCABLES.Op.apply(this,arguments);\nconst op=this;\n";
let codeFoot = "\n\n};\n\n" + name + ".prototype = new CABLES.Op();\n";
codeHead += name + " = class extends CABLES.Op \n{";
codeHead += "constructor()\n{ super(...arguments);\nconst op=this;const attachments=op.attachments={};\n";
let codeFoot = "}\n\n};\n\n";
codeFoot += "new " + name + "();\n";
const opCode = codeHead + code + codeFoot;

const errorEl = document.createElement("script");
errorEl.id = "customop-error-" + op.id;
errorEl.type = "text/javascript";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
"type": "deprecation",
"author": "stephan",
"date": 1719915896310
},
{
"message": "refactor to use new op class",
"type": "improvement",
"author": "stephan",
"date": 1737112571269
}
],
"authorName": "stephan",
Expand Down

0 comments on commit ec20a85

Please sign in to comment.