You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently when things such as syntax errors are thrown, a pretty confusing stack trace is returned. For example. Given the following user code:
functiona(){
[stdin]:2
ESS__, output: $STDOUT};
console._log(JSON.stringify(json));
} catch(ex){
^^^^^
SyntaxError: Unexpected token catch
at Object. ([stdin]-wrapper:6:22)
at Module._compile (module.js:456:26)
at evalScript (node.js:532:25)
at Socket. (node.js:154:11)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
I'm currently using a regexp to pull out the basic error message. So we get: SyntaxError: Unexpected token catch
User thinks to himself: Catch? WTF? There is no catch in my code...
The problem stems from the fact that we are combining kata framework code along with the user submitted code. We need to wrap a try/catch around the user's solution so that if there are any errors, we can catch them and send them out as a JSON response.
So the above code gets turned into something along these lines:
This isn't an issue with the current system because there is no need to wrap the code, since the node runner uses a shovel script along with the built-in node sandbox. The shovel/shim does the wrapping for us, but it happens in a seperate file.
In the case of Ruby code, we actually pre-check the code before attempting to execute it using a Ruby parsing engine.
Ideally we can remedy this for all lanuages by using a format that is more natural to typical programming... using seperate files. In the case of JavaScript we could create a shim that does this:
Currently when things such as syntax errors are thrown, a pretty confusing stack trace is returned. For example. Given the following user code:
I'm currently using a regexp to pull out the basic error message. So we get:
SyntaxError: Unexpected token catch
User thinks to himself: Catch? WTF? There is no catch in my code...
The problem stems from the fact that we are combining kata framework code along with the user submitted code. We need to wrap a try/catch around the user's solution so that if there are any errors, we can catch them and send them out as a JSON response.
So the above code gets turned into something along these lines:
This isn't an issue with the current system because there is no need to wrap the code, since the node runner uses a shovel script along with the built-in node sandbox. The shovel/shim does the wrapping for us, but it happens in a seperate file.
In the case of Ruby code, we actually pre-check the code before attempting to execute it using a Ruby parsing engine.
Ideally we can remedy this for all lanuages by using a format that is more natural to typical programming... using seperate files. In the case of JavaScript we could create a shim that does this:
The ruby version would look much the same.
The text was updated successfully, but these errors were encountered: