forked from cory/tildefriends
Report attempts to call tfrpc methods that aren't registered.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4306 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
3038138909
commit
7d9b627f37
@ -39,9 +39,9 @@ function send(response) {
|
|||||||
|
|
||||||
function call_rpc(message) {
|
function call_rpc(message) {
|
||||||
if (message && message.message === 'tfrpc') {
|
if (message && message.message === 'tfrpc') {
|
||||||
let method = g_api[message.method];
|
|
||||||
let id = message.id;
|
let id = message.id;
|
||||||
if (message.method) {
|
if (message.method) {
|
||||||
|
let method = g_api[message.method];
|
||||||
if (method) {
|
if (method) {
|
||||||
try {
|
try {
|
||||||
Promise.resolve(method(...message.params)).then(function(result) {
|
Promise.resolve(method(...message.params)).then(function(result) {
|
||||||
@ -53,7 +53,7 @@ function call_rpc(message) {
|
|||||||
send({message: 'tfrpc', id: id, error: error});
|
send({message: 'tfrpc', id: id, error: error});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(message.method + ' not found.');
|
send({message: 'tfrpc', id: id, error: `Method '${message.method}' not found.`});
|
||||||
}
|
}
|
||||||
} else if (message.error !== undefined) {
|
} else if (message.error !== undefined) {
|
||||||
if (g_calls[id]) {
|
if (g_calls[id]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user