ExpectIt icon indicating copy to clipboard operation
ExpectIt copied to clipboard

Not correct Exception on expect operation

Open WestDragon opened this issue 6 years ago • 2 comments

in class SingleInputExpect on method <R extends Result> R expect(long timeoutMs, Matcher<R> matcher) throws IOException on 105 line;

If copierFuture contains a thread with an exception (example SocketException) method return IOException with message Expect operation fails (timeout: 20000 ms) for matcher: contains('<-/MSG1>')].

But this message is not true.

2018-10-18 23 24 04

2018-10-18 23 24 43

maybe this solve problem: `

if (copierFuture == null) {
        throw new IllegalStateException("Not started");
    }
    if (copierFuture.isCancelled()){
        throw new IllegalStateException("Future is canceled");
    }
    try {
        copierFuture.get();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    } catch (ExecutionException e) {
        try {
            throw e.getCause();
        } catch (IOException ioEx) {
            throw ioEx;
        } catch (Throwable throwable) {
            throw new RuntimeException(throwable);
        }
    }

`

WestDragon avatar Oct 18 '18 20:10 WestDragon

If you change your application code to log the exception object, not only the message, you will see the root cause of the IOException (ie Socket exception) thrown from the library, something like this:

Logger.error("Expect matching error", e);

agavrilov76 avatar Sep 15 '19 13:09 agavrilov76

I'm confused at what is not correct. I see <-/ and </ two different things in the 2nd screenshot.

starlightdreamer avatar May 06 '21 01:05 starlightdreamer