groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <pa...@asert.com.au>
Subject Re: Catch clause difference
Date Mon, 08 Jan 2018 13:58:50 GMT
What does printing out `nse` in both cases show?

On Mon, Jan 8, 2018 at 11:02 PM, Mohan Radhakrishnan <
radhakrishnan.mohan@gmail.com> wrote:

> Hello,
>
> These catch clauses are somehow different from each other. Why  ?
>
> In the first case 'NoSuchElementException' is somehow escaping the
> 'catch' block. My test fails.
>
> But the second clause succeeds as expected.
>
> Clause 1 :
>
> catch( NoSuchElementException nse ){
>
>     throw new NoSuchWidgetException( " Element " + by.toString() + " not found" +
>                                      " after polling for [" + pollingInterval.longValue()
+
>                                      "] with timeout set to [" + timeOut.longValue()
);
> }
>
>
> Clause 2 :
>
> try{
>     WaitForWidget<Widget> wait =
>     new WaitForWidget<WebDriver>(wd).
>                             pollingEvery(pollingInterval.longValue(),unit).
>                             withTimeout(timeOut.longValue(),unit).
>                             withMessage(supplierClosure)
>
>     wait.until( {  wd.findElement( by )} as Function )
> }catch(  nse ){
>     throw new NoSuchWidgetException( " Element " + by.toString() + " not found" +
>                                      " after polling for [" + pollingInterval.longValue()
+
>                                      "] with timeout set to [" + timeOut.longValue()
);
> }
>
> Thanks,
> Mohan
>

Mime
View raw message