Skip to content

Commit fb73b5d

Browse files
committed
Removed @SneakyThrows and surrounded call() method of Callable with try-catch
1 parent 351eb16 commit fb73b5d

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/components/shadowdom/ShadowDomService.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ public static <TComponent extends WebComponent, TFindStrategy extends FindStrate
100100
return componentList;
101101
}
102102

103-
@SneakyThrows
104103
private static String[] getAbsoluteCss(ShadowRoot shadowRoot, String locator) {
105104
Callable<String[]> js = () -> {
106105
return ((ArrayList<String>)shadowRoot
@@ -118,13 +117,16 @@ private static String[] getAbsoluteCss(ShadowRoot shadowRoot, String locator) {
118117
throw new IllegalArgumentException();
119118
}
120119
}, Duration.ofSeconds(ConfigurationService.get(WebSettings.class).getTimeoutSettings().getElementWaitTimeout()), Duration.ofSeconds(1), false)) {
121-
return js.call();
120+
try {
121+
return js.call();
122+
} catch (Exception e) {
123+
throw new RuntimeException(e);
124+
}
122125
} else {
123126
throw new IllegalArgumentException("No elements inside the shadow DOM were found with the locator: " + locator);
124127
}
125128
}
126129

127-
@SneakyThrows
128130
private static String[] getRelativeCss(ShadowRoot shadowRoot, String locator, String parentLocator) {
129131
Callable<String[]> js = () -> {
130132
return ((ArrayList<String>)shadowRoot
@@ -143,7 +145,11 @@ private static String[] getRelativeCss(ShadowRoot shadowRoot, String locator, St
143145
throw new IllegalArgumentException();
144146
}
145147
}, Duration.ofSeconds(ConfigurationService.get(WebSettings.class).getTimeoutSettings().getElementWaitTimeout()), Duration.ofSeconds(1), false)) {
146-
return js.call();
148+
try {
149+
return js.call();
150+
} catch (Exception e) {
151+
throw new RuntimeException(e);
152+
}
147153
} else {
148154
throw new IllegalArgumentException("No elements inside the shadow DOM were found with the locator: " + locator);
149155
}

bellatrix.web/src/main/java/solutions/bellatrix/web/components/shadowdom/ShadowDomService.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public static <TComponent extends WebComponent, TFindStrategy extends FindStrate
103103
return componentList;
104104
}
105105

106-
@SneakyThrows
107106
private static String[] getAbsoluteCss(ShadowRoot shadowRoot, String locator) {
108107
Callable<String[]> js = () -> {
109108
return shadowRoot.getJavaScriptService()
@@ -123,13 +122,16 @@ private static String[] getAbsoluteCss(ShadowRoot shadowRoot, String locator) {
123122
throw new IllegalArgumentException();
124123
}
125124
}, Duration.ofSeconds(ConfigurationService.get(WebSettings.class).getTimeoutSettings().getElementWaitTimeout()), Duration.ofSeconds(1), false)) {
126-
return js.call();
125+
try {
126+
return js.call();
127+
} catch (Exception e) {
128+
throw new RuntimeException(e);
129+
}
127130
} else {
128131
throw new IllegalArgumentException("No elements inside the shadow DOM were found with the locator: " + locator);
129132
}
130133
}
131134

132-
@SneakyThrows
133135
private static String[] getRelativeCss(ShadowRoot shadowRoot, String locator, String parentLocator) {
134136
Callable<String[]> js = () -> {
135137
return shadowRoot.getJavaScriptService()
@@ -149,7 +151,11 @@ private static String[] getRelativeCss(ShadowRoot shadowRoot, String locator, St
149151
throw new IllegalArgumentException();
150152
}
151153
}, Duration.ofSeconds(ConfigurationService.get(WebSettings.class).getTimeoutSettings().getElementWaitTimeout()), Duration.ofSeconds(1), false)) {
152-
return js.call();
154+
try {
155+
return js.call();
156+
} catch (Exception e) {
157+
throw new RuntimeException(e);
158+
}
153159
} else {
154160
throw new IllegalArgumentException("No elements inside the shadow DOM were found with the locator: " + locator);
155161
}

0 commit comments

Comments
 (0)