mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 07:24:52 +09:00
Emitt more useful error on parse error
Rethrow parse errors with the JSON content that failed to parse for JSON content sent to Clusterio from Factorio.
This commit is contained in:
1 parent
b43a181bf4
commit
5daa492f68
1 file changed
+5
-1
@@ -605,7 +605,11 @@ class FactorioServer extends events.EventEmitter {
|
||||
let type = line.slice(channelEnd + 1, channelEnd + 2).toString("utf-8");
|
||||
let content;
|
||||
if (type === "j") {
|
||||
content = JSON.parse(line.slice(channelEnd + 2).toString("utf-8"));
|
||||
try {
|
||||
content = JSON.parse(line.slice(channelEnd + 2).toString("utf-8"));
|
||||
} catch (err) {
|
||||
throw new Error(`Malformed JSON to ${channel}: ${line.slice(channelEnd + 2).toString("utf-8")}`);
|
||||
}
|
||||
|
||||
} else if (type === "f") {
|
||||
let fileName = line.slice(channelEnd + 2).toString("utf-8");
|
||||
|
||||
Reference in new issue
Block a user