fix: replace generic Error with OperationError in Thrift serialization and deserialization operations
This commit is contained in:
parent
294f597393
commit
064d625954
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
import {
|
import {
|
||||||
parseBinaryProtocol,
|
parseBinaryProtocol,
|
||||||
parseCompactProtocol
|
parseCompactProtocol
|
||||||
@ -56,7 +57,7 @@ class ThriftDeserialize extends Operation {
|
|||||||
}
|
}
|
||||||
return JSON.stringify(decodedObject, null, 4);
|
return JSON.stringify(decodedObject, null, 4);
|
||||||
} catch (err) {
|
} 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)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
import {
|
import {
|
||||||
buildBinaryStruct
|
buildBinaryStruct
|
||||||
} from "../lib/Thrift.mjs";
|
} from "../lib/Thrift.mjs";
|
||||||
@ -42,7 +43,7 @@ class ThriftSerialize extends Operation {
|
|||||||
try {
|
try {
|
||||||
parsedInput = JSON.parse(input);
|
parsedInput = JSON.parse(input);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error("Input must be valid JSON.");
|
throw new OperationError("Input must be valid JSON.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const bytes = [];
|
const bytes = [];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user