MCPcopy
hub / github.com/DulLabs/bhai-lang / executeCode

Function executeCode

apps/docs/components/Code/index.tsx:45–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43 };
44
45 const executeCode = () => {
46 let orignalConsoleLog = console.log;
47 const outputList = [];
48 let isExecusionSuccess = true;
49 console.log = function (...args) {
50 outputList.push({ value: args.join("\n"), isError: false });
51 };
52
53 try {
54 interpreter.interpret(code);
55 } catch (e) {
56 if (e instanceof Error) {
57 isExecusionSuccess = false;
58 outputList.push({ value: e.message, isError: true });
59 } else {
60 console.error(e);
61 }
62 }
63
64 sendEvents("CodeExecuted", {success: isExecusionSuccess});
65
66 setIsSuccess(isExecusionSuccess);
67 setOutput(outputList);
68 console.log = orignalConsoleLog;
69 };
70
71 const clearCode = () => {
72 sendEvents("CodeCleared");

Callers

nothing calls this directly

Calls 2

sendEventsFunction · 0.90
interpretMethod · 0.80

Tested by

no test coverage detected