fix: replace generic Error with OperationError in Thrift serialization and deserialization operations

This commit is contained in:
engin0223 2026-06-06 13:37:49 +03:00
parent 294f597393
commit 064d625954
2 changed files with 4 additions and 2 deletions

View File

@ -6,6 +6,7 @@
*/
import Operation from "../Operation.mjs";
import OperationError from "../errors/OperationError.mjs";
import {
parseBinaryProtocol,
parseCompactProtocol
@ -56,7 +57,7 @@ class ThriftDeserialize extends Operation {
}
return JSON.stringify(decodedObject, null, 4);
} catch (err) {
return `Error decoding Thrift payload: ${err.message}\n\nPartial output:\n${JSON.stringify(decodedObject, null, 4)}`;
throw new OperationError(`Error decoding Thrift payload: ${err.message}\n\nPartial output:\n${JSON.stringify(decodedObject, null, 4)}`);
}
}
}

View File

@ -6,6 +6,7 @@
*/
import Operation from "../Operation.mjs";
import OperationError from "../errors/OperationError.mjs";
import {
buildBinaryStruct
} from "../lib/Thrift.mjs";
@ -42,7 +43,7 @@ class ThriftSerialize extends Operation {
try {
parsedInput = JSON.parse(input);
} catch (e) {
throw new Error("Input must be valid JSON.");
throw new OperationError("Input must be valid JSON.");
}
const bytes = [];