From 24bdee229bf292674bd37a5ee8f46c87c32cd610 Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Fri, 19 Jan 2024 01:29:45 +0100 Subject: [PATCH] refactor: simplify re-throw --- addon/src/-private/better-errors.js | 1 + addon/src/macros/getter.js | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addon/src/-private/better-errors.js b/addon/src/-private/better-errors.js index a1aad63b..9973d7d0 100644 --- a/addon/src/-private/better-errors.js +++ b/addon/src/-private/better-errors.js @@ -78,6 +78,7 @@ function buildPropertyNamesPath(node) { path.unshift(Ceibo.meta(current).key); } + // replace "root" with "page" path[0] = 'page'; return path; diff --git a/addon/src/macros/getter.js b/addon/src/macros/getter.js index fd9d3ffb..87992902 100644 --- a/addon/src/macros/getter.js +++ b/addon/src/macros/getter.js @@ -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;