MCPcopy
hub / github.com/sindresorhus/execa / handleSerializationError

Function handleSerializationError

lib/ipc/validation.js:69–73  ·  view source on GitHub ↗
({error, methodName, isSubprocess, message})

Source from the content-addressed store, hash-verified

67// Better error message when sending messages which cannot be serialized.
68// Works with both `serialization: 'advanced'` and `serialization: 'json'`.
69export const handleSerializationError = ({error, methodName, isSubprocess, message}) => {
70 if (isSerializationError(error)) {
71 throw new Error(`${getMethodName(methodName, isSubprocess)}'s argument type is invalid: the message cannot be serialized: ${String(message)}.`, {cause: error});
72 }
73};
74
75const isSerializationError = ({code, message}) => SERIALIZATION_ERROR_CODES.has(code)
76 || SERIALIZATION_ERROR_MESSAGES.some(serializationErrorMessage => message.includes(serializationErrorMessage));

Callers 1

sendOneMessageFunction · 0.90

Calls 2

isSerializationErrorFunction · 0.85
getMethodNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…