Skip to content

Commit

Permalink
add interpreter auto fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
SchneeHertz committed Sep 10, 2023
1 parent a24d0bb commit 558978e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions modules/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ const env = {
const context = new vm.createContext(env)

const javaScriptInterpreterPowerful = ({ code }) => {
const script = new vm.Script(code)
let result = script.runInContext(context)
return JSON.stringify(result)
try {
const script = new vm.Script(code)
let result = script.runInContext(context)
return JSON.stringify(result)
} catch (error) {
return error
}
}

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 558978e

Please sign in to comment.