-
Notifications
You must be signed in to change notification settings - Fork 4
Feature: Return errors separately #17
Copy link
Copy link
Open
Description
It would be nice if it were possible to tell the difference between when code resulted in an error and when it successfully returned a value. I'm thinking of something like this:
var engine = require("engine.js").engine;
var client = engine.client.create();
var task = client.createTask();
task.setContext("(function(locals){ return { add: function(a,b){ return a+b } } })");
task.setLocals({});
task.setCode('sub(1,2)');
task.on('eval', function(err, data){
if(err) console.log(err); // ReferenceError: sub is not defined
console.log(data) // undefined
});
task.run();Or maybe a different event:
task.on('eval', function(data){
console.log(data);
});
task.on('error', function(err){
console.log(err); // ReferenceError: sub is not defined
});I think I should be able to implement this feature and will submit a pull request when I get a chance.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels