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
I do not know if this is an error or is there is a way to catch this error, I have introduced an error in this example line 66myerror is a referenceError , however I cannot catch this javascript error in my .net code and this error causes that my app closes automatically. I'm running a code like this in a big project and this is a big problem for me.
using System;
using System.Threading.Tasks;
using EdgeJs;
using System.IO;
using System.Threading;
class Program
{
public static async void Start()
{
// Define an event handler to be called for every message from the client
var onMessage = (Func<object, Task<object>>)(async (message) =>
{
return "Event number# " + ((string)message);
});
var onMessage2 = (Func<object, Task<object>>)(async (message) =>
{
return "Event 2 number# " + ((string)message);
});
var sendCommand = (Func<object, Task<object>>)(async (message) =>
{
return "Command has sent" + ((string)message);
});
var createScriptListener = Edge.Func(@"
const EventEmitter = require('events');
class MyEmitter extends EventEmitter {}
var i = 0;
return function (options, cb) {
console.log('new event emitter');
var event = new MyEmitter();
event.on('event', function (message) {
options.onMessage(message, function (error, result) {
if (error) throw error;
console.log(result);
});
});
event.on('event2', function (message) {
options.onMessage2(message, function (error, result) {
if (error) throw error;
console.log(result);
});
});
event.on('sendCommand', function (message, done) {
options.sendCommand(message , function (error, result) {
if (error) throw error;
console.log(result);
myerror
done(null, result)
});
});
event.on('close', function(){
console.log('events eventemitter bye');
process.exit(0);
});
event.emit('sendCommand', 'data from script', function(err, data){
console.log('printing from script: ' + data);
});
cb();
};
");
try
{
await createScriptListener(new
{
onMessage = onMessage,
onMessage2 = onMessage2,
sendCommand = sendCommand
});
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
static void Main(string[] args)
{
try
{
Task.Run((Action)Start);
new ManualResetEvent(false).WaitOne();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
The text was updated successfully, but these errors were encountered:
Hello,
I do not know if this is an error or is there is a way to catch this error, I have introduced an error in this example
line 66
myerror
is areferenceError
, however I cannot catch this javascript error in my .net code and this error causes that my app closes automatically. I'm running a code like this in a big project and this is a big problem for me.The text was updated successfully, but these errors were encountered: