From 064d625954a9eddcae63aa83cd0ae3c91cc5c585 Mon Sep 17 00:00:00 2001 From: engin0223 Date: Sat, 6 Jun 2026 13:37:49 +0300 Subject: [PATCH] fix: replace generic Error with OperationError in Thrift serialization and deserialization operations --- src/core/operations/ThriftDeserialize.mjs | 3 ++- src/core/operations/ThriftSerialize.mjs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 = [];