Skip to content
Snippets Groups Projects
Commit 9817d145 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Catch and print exceptions

Because of the way this script is invoked from str_cmds.js (using js.exec)
any exceptions were just silent failures, making debugging issues
(e.g. the recent regression with the global ascii() function) difficult.
parent de1132e2
No related branches found
No related tags found
No related merge requests found
...@@ -87,45 +87,49 @@ if(!mqtt.subscribe(terminal_topic)) { ...@@ -87,45 +87,49 @@ if(!mqtt.subscribe(terminal_topic)) {
} }
print("*** Synchronet MQTT Spy on Node " + node_num + ": Ctrl-C to Abort ***\r\n"); print("*** Synchronet MQTT Spy on Node " + node_num + ": Ctrl-C to Abort ***\r\n");
while(!js.terminated) { try {
var msg = mqtt.read(/* timeout: */10, /* verbose: */true); while(!js.terminated) {
if(msg) { var msg = mqtt.read(/* timeout: */10, /* verbose: */true);
if(msg.topic == out_topic) if(msg) {
output(msg.data); if(msg.topic == out_topic)
else if(msg.topic == status_topic) { output(msg.data);
var new_status = parseInt(msg.data, 10); else if(msg.topic == status_topic) {
if(new_status != node_status) { var new_status = parseInt(msg.data, 10);
node_status = new_status; if(new_status != node_status) {
print("\r\nNew node status: " + NodeStatus[node_status]); node_status = new_status;
print("\r\nNew node status: " + NodeStatus[node_status]);
}
}
else if(msg.topic == terminal_topic) {
node_charset = msg.data.split('\t')[4];
} }
} }
else if(msg.topic == terminal_topic) { if(js.global.console) {
node_charset = msg.data.split('\t')[4]; if(console.aborted || !bbs.online)
}
}
if(js.global.console) {
if(console.aborted || !bbs.online)
break;
console.line_counter = 0;
while(bbs.online && !console.aborted) {
var key = ascii(console.getbyte(10));
if(!key)
break; break;
if(key == CTRL_C) console.line_counter = 0;
console.aborted = true; while(bbs.online && !console.aborted) {
if(key == KEY_ESC) { var key = ascii(console.getbyte(10));
key = ascii(console.getbyte(500));
if(!key) if(!key)
key = KEY_ESC; break;
else if(key != '[') if(key == CTRL_C)
key = KEY_ESC + key; console.aborted = true;
else if(key == KEY_ESC) {
key = get_ansi_seq(); key = ascii(console.getbyte(500));
if(!key)
key = KEY_ESC;
else if(key != '[')
key = KEY_ESC + key;
else
key = get_ansi_seq();
}
if(key)
mqtt.publish(in_topic, key);
} }
if(key)
mqtt.publish(in_topic, key);
} }
} }
} catch(e) {
print(e);
} }
print(); print();
print("Done spying"); print("Done spying");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment