diff --git a/src/core/operations/ThriftDeserialize.mjs b/src/core/operations/ThriftDeserialize.mjs index 0a00af70..4187849d 100644 --- a/src/core/operations/ThriftDeserialize.mjs +++ b/src/core/operations/ThriftDeserialize.mjs @@ -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)}`); } } } diff --git a/src/core/operations/ThriftSerialize.mjs b/src/core/operations/ThriftSerialize.mjs index b7c06fe5..1584f033 100644 --- a/src/core/operations/ThriftSerialize.mjs +++ b/src/core/operations/ThriftSerialize.mjs @@ -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 = [];