From 9ae7e46855bad9f20f4454d760b5a42a53ab060e Mon Sep 17 00:00:00 2001 From: Moon Man Date: Sun, 28 Jan 2024 11:57:08 -0500 Subject: [PATCH] more logging --- dist/bert.js | 4 ++-- dist/main.js | 4 ++-- src/bert.ts | 4 ++-- src/main.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/bert.js b/dist/bert.js index f5384d5..a9a08b6 100644 --- a/dist/bert.js +++ b/dist/bert.js @@ -93,11 +93,11 @@ export class Bert { }; decode = (buffer) => { if (buffer[0] !== Types.BERT_START) { - throw new Error("Not a valid BERT"); + throw new Error("Invalid BERT start magic"); } const obj = this.#decode(buffer.subarray(1)); if (obj.rest.length !== 0) { - throw new Error("Invalid BERT"); + throw new Error(`Invalid BERT, remainder was: ${obj.rest.length}`); } return obj.value; }; diff --git a/dist/main.js b/dist/main.js index 40eeb4f..7c1d304 100644 --- a/dist/main.js +++ b/dist/main.js @@ -17,7 +17,7 @@ export class Port extends Duplex { const lenBytes = process.stdin.read(4); if (lenBytes) { const termLen = this.bert.bytesToInt(lenBytes, 4, true); - process.stderr.write(`Got term length: ${termLen}\n`); + process.stderr.write(`Got incoming term length: ${termLen}\n`); const termBytes = process.stdin.read(termLen); if (termBytes) { const decoded = this.bert.decode(termBytes); @@ -25,7 +25,7 @@ export class Port extends Duplex { return decoded; } else { - process.stderr.write(`Read should have gotten ${termLen} bytes.\n`); + process.stderr.write(`Term read got erroneous null.\n`); return null; } } diff --git a/src/bert.ts b/src/bert.ts index 777f00d..fbfd387 100644 --- a/src/bert.ts +++ b/src/bert.ts @@ -112,13 +112,13 @@ export class Bert { decode = (buffer: Buffer) => { if (buffer[0] !== Types.BERT_START) { - throw new Error("Not a valid BERT"); + throw new Error("Invalid BERT start magic"); } const obj = this.#decode(buffer.subarray(1)); if (obj.rest.length !== 0) { - throw new Error("Invalid BERT"); + throw new Error(`Invalid BERT, remainder was: ${obj.rest.length}`); } return obj.value; diff --git a/src/main.ts b/src/main.ts index d9ca9a2..0a43e32 100644 --- a/src/main.ts +++ b/src/main.ts @@ -22,7 +22,7 @@ export class Port extends Duplex { const lenBytes = process.stdin.read(4); if (lenBytes) { const termLen = this.bert.bytesToInt(lenBytes, 4, true); - process.stderr.write(`Got term length: ${termLen}\n`); + process.stderr.write(`Got incoming term length: ${termLen}\n`); const termBytes = process.stdin.read(termLen); if (termBytes) { @@ -31,7 +31,7 @@ export class Port extends Duplex { return decoded; } else { - process.stderr.write(`Read should have gotten ${termLen} bytes.\n`); + process.stderr.write(`Term read got erroneous null.\n`); return null; } }