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

Leverage error “cause” for wrapping render errors. #170

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

theengineear
Copy link
Collaborator

Because some template engines can throw immutable errors, it’s safer and better to use an “error cause” to chain the old error to our own versus trying to mutate the original.

Closes #128.

Because some template engines can throw _immutable_ errors, it’s safer
and better to use an “error cause” to _chain_ the old error to our own
versus trying to mutate the original.

Closes #128.
@@ -123,8 +123,8 @@ export default class XElement extends HTMLElement {
render(renderRoot, result);
} catch (error) {
const pathString = XElement.#toPathString(this);
error.message = `${error.message} — Invalid template for "${this.constructor.name}" at path "${pathString}"`;
throw error;
const message = `${error.message} — Invalid template for "${this.constructor.name}" at path "${pathString}"`;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, for now, we continue to embed the original error message. Eventually, we can simply remove it once the tooling catches up — see #169.

@theengineear theengineear merged commit 1ebdedc into main Feb 13, 2024
1 check passed
@theengineear theengineear deleted the leverage-error-cause branch February 13, 2024 23:40
@theengineear
Copy link
Collaborator Author

FYI @klebba — super small change to leverage error “cause”. It’s a slightly safer way of wrapping errors.

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.

Use error cause for template errors.
1 participant