Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added component traces to errors #236

Merged
merged 1 commit into from Nov 5, 2023

Conversation

ncpa0cpl
Copy link
Collaborator

@ncpa0cpl ncpa0cpl commented Nov 5, 2023

Added traces to errors thrown by the renderer to allow easier debugging. This is achieved by catching any errors during rendering and when that happens, throwing custom errors instead. Original errors can still be accessed via the .cause property.

Example

If an error occurs in a component called MyComponent you might see an error like this:

JsxteRendererError: The below error has occurred in:
<App>
<html>
<body>
<Layout>
<div>
<MyComponent>

Rendering has failed due to an error: <Actual error message>

Accessing the original error

try {
  const html = renderToHtml(<App />);
} catch (error) {
  error; // -> JsxteRendererError
  error.cause; // -> original error
}

@ncpa0cpl ncpa0cpl merged commit 53a7376 into master Nov 5, 2023
3 checks passed
@ncpa0cpl ncpa0cpl deleted the feat/component-error-traces branch November 5, 2023 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant