worker-factory
Version:
A little factory function to create a JSON-RPC based Web Worker implementation.
7 lines • 1.1 kB
JavaScript
const JSON_RPC_ERROR_CODES = { INTERNAL_ERROR: -32603, INVALID_PARAMS: -32602, METHOD_NOT_FOUND: -32601 };
const createErrorWithMessageAndStatus = (message, status) => Object.assign(new Error(message), { status });
export const renderMethodNotFoundError = (method) => createErrorWithMessageAndStatus(`The requested method called "${method}" is not supported.`, JSON_RPC_ERROR_CODES.METHOD_NOT_FOUND);
export const renderMissingResponseError = (method) => createErrorWithMessageAndStatus(`The handler of the method called "${method}" returned no required result.`, JSON_RPC_ERROR_CODES.INTERNAL_ERROR);
export const renderUnexpectedResultError = (method) => createErrorWithMessageAndStatus(`The handler of the method called "${method}" returned an unexpected result.`, JSON_RPC_ERROR_CODES.INTERNAL_ERROR);
export const renderUnknownPortIdError = (portId) => createErrorWithMessageAndStatus(`The specified parameter called "portId" with the given value "${portId}" does not identify a port connected to this worker.`, JSON_RPC_ERROR_CODES.INVALID_PARAMS);
//# sourceMappingURL=error-renderers.js.map