more logging
This commit is contained in:
parent
5c4f45a0dc
commit
9ae7e46855
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue