public String getVerboseMessage(boolean includeErrorIdAndIdentity) { return generateMessage(includeErrorIdAndIdentity) + "\n\n" + ErrorHelper.buildCausesMessage(getCause()); }
@Test public void testOnMessageFileNotFound() throws IOException { try { getResponse(new FileNotFoundException("Where is the file?")); fail("Was expecting UserException/FileNotFoundException"); } catch(UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(FileNotFoundException.class, e.getCause().getClass()); assertEquals("Where is the file?", e.getCause().getMessage()); } }
@Test public void testOnMessageIOException() throws IOException { try { getResponse(0L, 4096, new IOException("Something happened")); fail("Was expecting UserException/IOException"); } catch(UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(IOException.class, e.getCause().getClass()); assertEquals("Something happened", e.getCause().getMessage()); } } }
@Test public void testOnMessageFileNotFound() throws IOException { try { getResponse(TEST_PATH_STRING, new FileNotFoundException("Where is the file?")); fail("Was expecting UserException/FileNotFoundException"); } catch(UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(FileNotFoundException.class, e.getCause().getClass()); assertEquals("Where is the file?", e.getCause().getMessage()); } }
@Test public void testOnMessageFileNotFound() throws IOException { try { getResponse(true, new FileNotFoundException("Where is the file?")); fail("Was expecting UserException/FileNotFoundException"); } catch(UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(FileNotFoundException.class, e.getCause().getClass()); assertEquals("Where is the file?", e.getCause().getMessage()); } }
@Test public void testOnMessageFileNotFound() throws IOException { try { getResponse(new FileNotFoundException("Where is the file?")); fail("Expected UserException/FileNoFoundExpection"); } catch(UserException e) { // Expected assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(FileNotFoundException.class, e.getCause().getClass()); assertEquals("Where is the file?", e.getCause().getMessage()); } }
@Test public void testOnMessageFileNotFound() throws IOException { try { getResponse(0L, 4096, new FileNotFoundException("Where is the file?")); fail("Was expecting UserException/FileNotFoundException"); } catch(UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(FileNotFoundException.class, e.getCause().getClass()); assertEquals("Where is the file?", e.getCause().getMessage()); } }
@Override public void submissionFailed(UserException ex) { // or !client.isActive() if (ex.getCause() instanceof ChannelClosedException) { if (reconnect()) { try { client.submitQuery(this, query); } catch (Exception e) { fail(e); } } else { fail(ex); } } else { fail(ex); } }
@Test public void testOnMessageFileNotFound() throws IOException { try { getResponse(FsPermission.getDirDefault(), new FileNotFoundException("Where is the file?")); fail("Was expecting UserException/FileNotFoundException"); } catch(UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(FileNotFoundException.class, e.getCause().getClass()); assertEquals("Where is the file?", e.getCause().getMessage()); } }
@Test public void testOnMessageIOException() throws IOException { try { getResponse(TEST_PATH_STRING, new IOException()); fail("Was expecting UserException/IOException"); } catch(UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(IOException.class, e.getCause().getClass()); } }
@Test public void testOnMessageIOException() throws IOException { try { getResponse(true, new IOException()); fail("Was expecting UserException/IOException"); } catch (UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(IOException.class, e.getCause().getClass()); } } }
@Test public void testOnMessageIOException() throws IOException { try { getResponse(new IOException()); fail("Was expecting UserException/IOException"); } catch (UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(IOException.class, e.getCause().getClass()); } } }
@Test public void testOnMessageIOException() throws IOException { try { getResponse(new IOException()); fail("Expected UserException/IOException"); } catch(UserException e) { // Expected assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(IOException.class, e.getCause().getClass()); } } }
@Test public void testOnMessageIOException() throws IOException { try { getResponse(FsPermission.getDirDefault(), new IOException()); fail("Was expecting UserException/IOException"); } catch (UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(IOException.class, e.getCause().getClass()); } } }
/** * returns or creates a DremioPBError object corresponding to this user exception. * * @param verbose should the error object contain the verbose error message ? * @return protobuf error object */ public DremioPBError getOrCreatePBError(final boolean verbose) { final DremioPBError.Builder builder = DremioPBError.newBuilder(); builder.setErrorType(errorType); builder.setErrorId(context.getErrorId()); if (context.getEndpoint() != null) { builder.setEndpoint(context.getEndpoint()); } builder.setMessage(getVerboseMessage()); builder.setOriginalMessage(getOriginalMessage()); if (getCause() != null) { // some unit tests use this information to make sure a specific exception was thrown in the server builder.setException(ErrorHelper.getWrapper(getCause())); } builder.addAllContext(context.getContextAsStrings()); if (rawAdditionalContext != null) { builder.setTypeSpecificContext(rawAdditionalContext); } return builder.build(); }
@Test public void testStreamWithCacheExpiration() throws IOException { TestRemoteIterator statuses = newRemoteIterator( new FileStatus(1337, false, 1, 4096, 1, 2, FsPermission.getFileDefault(), "testowner", "testgroup", new Path(TEST_PATH, "bar")), new FileStatus(0, true, 0, 0, 3, 4, FsPermission.getDirDefault(), "testowner", "testgroup", new Path(TEST_PATH, "baz")) ); final ListStatusContinuationHandle handle; { DFS.ListStatusResponse response = getResponse(TEST_PATH_STRING, statuses, 1, null); assertEquals(1, response.getStatusesList().size()); assertEquals(TEST_PATH_STRING + "/bar", response.getStatusesList().get(0).getPath()); assertTrue(response.hasHandle()); handle = response.getHandle(); assertTrue(getPDFSProtocol().isIteratorOpen(handle)); assertFalse(statuses.isClosed()); } // Moving ticker so that open iterators expire getTicker().advance(5, TimeUnit.MINUTES); try { getResponse(TEST_PATH_STRING, null, 1, handle); fail(); } catch (UserException e) { assertEquals(ErrorType.IO_EXCEPTION, e.getErrorType()); assertSame(IOException.class, e.getCause().getClass()); } }