Skip to content

Commit

Permalink
Leverage error “cause” for wrapping render errors.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
theengineear committed Feb 13, 2024
1 parent 9f03e5d commit e12a9df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions x-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`;
throw new Error(message, { cause: error });
}
}

Expand Down

0 comments on commit e12a9df

Please sign in to comment.