From f36d74d663687a36d1f5056ecefb210b2a6d8273 Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 31 Oct 2024 18:20:31 +0300 Subject: [PATCH] rename ensureError function to convertToError --- node_package/src/serverRenderReactComponent.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node_package/src/serverRenderReactComponent.ts b/node_package/src/serverRenderReactComponent.ts index c4c9b8e3a..43d46bf23 100644 --- a/node_package/src/serverRenderReactComponent.ts +++ b/node_package/src/serverRenderReactComponent.ts @@ -27,7 +27,7 @@ type RenderOptions = { renderingReturnsPromises: boolean; }; -function ensureError(e: unknown): Error { +function convertToError(e: unknown): Error { return e instanceof Error ? e : new Error(String(e)); } @@ -96,7 +96,7 @@ function handleRenderingError(e: unknown, options: { componentName: string, thro if (options.throwJsErrors) { throw e; } - const error = ensureError(e); + const error = convertToError(e); return { hasErrors: true, result: handleError({ e: error, name: options.componentName, serverSide: true }), @@ -266,7 +266,7 @@ const streamRenderReactComponent = (reactRenderingResult: ReactElement, options: const renderingStream = ReactDOMServer.renderToPipeableStream(reactRenderingResult, { onShellError(e) { - const error = ensureError(e); + const error = convertToError(e); renderState.hasErrors = true; renderState.error = error; @@ -286,7 +286,7 @@ const streamRenderReactComponent = (reactRenderingResult: ReactElement, options: if (!renderState.isShellReady) { return; } - const error = ensureError(e); + const error = convertToError(e); if (throwJsErrors) { emitError(error); } @@ -323,7 +323,7 @@ export const streamServerRenderedReactComponent = (options: RenderParams): Reada throw e; } - const error = ensureError(e); + const error = convertToError(e); const htmlResult = handleError({ e: error, name: componentName, serverSide: true }); const jsonResult = JSON.stringify(createResultObject(htmlResult, buildConsoleReplay(), { hasErrors: true, error, result: null })); return stringToStream(jsonResult);