Commit b533d239 authored by yann300's avatar yann300

wrap call with try catch

parent c950c2af
...@@ -19,6 +19,7 @@ class Router { ...@@ -19,6 +19,7 @@ class Router {
} }
call (callid, name, fn, args) { call (callid, name, fn, args) {
try {
servicesList[name][fn](args, (error, data) => { servicesList[name][fn](args, (error, data) => {
var response = { var response = {
id: callid, id: callid,
...@@ -29,6 +30,18 @@ class Router { ...@@ -29,6 +30,18 @@ class Router {
} }
this.websocket.send(JSON.stringify(response)) this.websocket.send(JSON.stringify(response))
}) })
} catch (e) {
var msg = 'Unexpected Error ' + e.message
console.log('\x1b[31m%s\x1b[0m', '[ERR] ' + msg)
if (this.websocket) {
this.websocket.send(JSON.stringify({
id: callid,
type: 'reply',
scope: name,
error: msg
}))
}
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment