Skip to content

Commit

Permalink
refactor: simplify re-throw
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0gr committed Jan 19, 2024
1 parent affca42 commit 24bdee2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions addon/src/-private/better-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function buildPropertyNamesPath(node) {
path.unshift(Ceibo.meta(current).key);
}

// replace "root" with "page"
path[0] = 'page';

return path;
Expand Down
8 changes: 3 additions & 5 deletions addon/src/macros/getter.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ export function getter(fn) {
} catch (e) {
if (e instanceof PageObjectError) {
if (!e.cause.key) {
// re-throw with a page object key to have a complete error message
const { message, node, selector } = e.cause;
const wrapperError = new PageObjectError(message, {
// re-throw with a `pageObjectKey` to have a complete error message
const wrapperError = new PageObjectError(e.cause.message, {
cause: {
...e.cause,
key: pageObjectKey,
node,
selector,
},
});
wrapperError.stack = e.stack;
Expand Down

0 comments on commit 24bdee2

Please sign in to comment.