/** * Creates a new user exception builder . * * @see com.dremio.exec.proto.UserBitShared.DremioPBError.ErrorType#VALIDATION * @return user exception builder */ public static Builder validationError() { return validationError(null); }
/** * Creates a new user exception builder. * * @see com.dremio.exec.proto.UserBitShared.DremioPBError.ErrorType#DATA_READ * @return user exception builder */ public static Builder dataReadError() { return dataReadError(null); }
public static List<QueryError> of(UserException e) { switch(e.getErrorType()) { case PARSE: case PLAN: case VALIDATION: return ImmutableList.of(new QueryError(e.getMessage(), rangeOf(e))); default: return ImmutableList.of(); } }
private UserException.Builder getExceptionBuilder(final Exception ex, final HashAggErrorType errorType) { switch (errorType) { case SPILL_READ: return (ex == null) ? (UserException.dataReadError()) : (UserException.dataReadError(ex)); case SPILL_WRITE: return (ex == null) ? (UserException.dataWriteError()) : (UserException.dataWriteError(ex)); case OOM: return (ex == null) ? (UserException.memoryError()) : (UserException.memoryError(ex)); default: /* should never be hit since VectorizedHashAggOperator controls the operator type */ return null; } }
public static QueryProfile.Builder addError(UserException ex, QueryProfile.Builder profileBuilder) { if (ex != null) { profileBuilder.setError(ex.getMessage()) .setVerboseError(ex.getVerboseMessage(false)) .setErrorId(ex.getErrorId()); if (ex.getErrorLocation() != null) { profileBuilder.setErrorNode(ex.getErrorLocation()); } } return profileBuilder; } }
@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()); } }
public void bad(String passwd, String err) throws Exception { try { SimpleUserService.validatePassword(passwd); fail("Password '" + passwd + "' should not be accepted."); } catch (UserException e) { assertEquals("Expected a VALIDATION error but got " + e.getErrorType(), ErrorType.VALIDATION, e.getErrorType()); assertTrue("Unexpected error message", e.getOriginalMessage().contains(err)); } }
@Test public void testBuildUserExceptionWithCause() { String message = "Test message"; UserException uex = UserException.dataWriteError(new RuntimeException(message)).build(logger); DremioPBError error = uex.getOrCreatePBError(false); // cause message should be used Assert.assertEquals(ErrorType.DATA_WRITE, error.getErrorType()); Assert.assertEquals(message, uex.getOriginalMessage()); }
/** * Creates a new user exception builder . * * @see com.dremio.exec.proto.UserBitShared.DremioPBError.ErrorType#UNSUPPORTED_OPERATION * @return user exception builder */ public static Builder unsupportedError() { return unsupportedError(null); }
@Override protected void describeMismatchSafely(final UserException e, final Description description) { description.appendText("UserException thrown was of type: ") .appendValue(e.getErrorType().toString()); if (expectedMessage != null) { description.appendText(" with message: \"") .appendText(e.getMessage()) .appendText("\""); } if (expectedContexts != null) { description.appendValueList(" with contexts {", ",", "}", e.getContextStrings()); } } }
@Test public void testBuildUserExceptionWithUserExceptionCauseAndMessage() { String messageA = "Test message A"; String messageB = "Test message B"; UserException original = UserException.connectionError().message(messageA).build(logger); UserException uex = UserException.dataWriteError(wrap(original, 5)).message(messageB).build(logger); //builder should return the unwrapped original user exception and not build a new one Assert.assertEquals(original, uex); DremioPBError error = uex.getOrCreatePBError(false); Assert.assertEquals(messageA, uex.getOriginalMessage()); Assert.assertFalse(error.getMessage().contains(messageB)); // messageB should not be part of the context }
@Override public void submissionFailed(UserException ex) { logger.debug("Query failed: " + ex.getMessage()); }
@Override public Response toResponse(UserException exception) { final String errorMessage = exception.getErrorType() == ErrorType.SYSTEM ? SYSTEM_ERROR_MSG : exception.getOriginalMessage(); return Response.status(getStatus(exception)) .entity(new ErrorMessageWithContext( errorMessage, removeStatus(exception.getContextStrings()), sendStackTrace ? GenericErrorMessage.printStackTrace(exception): null )) .type(APPLICATION_JSON_TYPE) .build(); }
@Test public void testRemoteRuntimeException() throws Exception { UserRemoteException ure = UserRemoteException.create(UserException .unsupportedError(new UserRpcException(null, "user rpc exception", new RuntimeException("test message"))) .build(logger).getOrCreatePBError(false)); exception.expect(RuntimeException.class); exception.expectMessage("test message"); RpcException.propagateIfPossible(new RpcException(ure), TestException.class); } }
@Test public void testBuildUserExceptionWithFormattedMessage() { String format = "This is test #%d"; UserException uex = UserException.connectionError().message(format, 5).build(logger); DremioPBError error = uex.getOrCreatePBError(false); Assert.assertEquals(ErrorType.CONNECTION, error.getErrorType()); Assert.assertEquals(String.format(format, 5), uex.getOriginalMessage()); }
/** * Creates a new user exception builder . * * @see com.dremio.exec.proto.UserBitShared.DremioPBError.ErrorType#FUNCTION * @return user exception builder */ public static Builder functionError() { return functionError(null); }
@Test @Ignore public void testExceptionHandling() throws Exception { try { test("select * from cp.\"jsoninput/DRILL-2350.json\""); } catch(UserException e) { Assert.assertEquals(UserBitShared.DremioPBError.ErrorType.UNSUPPORTED_OPERATION, e.getOrCreatePBError(false).getErrorType()); String s = e.getMessage(); assertEquals("Expected Unsupported Operation Exception.", true, s.contains("Dremio does not support lists of different types.")); } }
@Test public void testBuildSystemException() { String message = "This is an exception"; UserException uex = UserException.systemError(new Exception(new RuntimeException(message))).build(logger); Assert.assertTrue(uex.getOriginalMessage().contains(message)); Assert.assertTrue(uex.getOriginalMessage().contains("RuntimeException")); DremioPBError error = uex.getOrCreatePBError(true); Assert.assertEquals(ErrorType.SYSTEM, error.getErrorType()); }
/** * Creates a new user exception builder. * * @see com.dremio.exec.proto.UserBitShared.DremioPBError.ErrorType#CONNECTION * @return user exception builder */ public static Builder connectionError() { return connectionError(null); }
/** * Creates a new user exception builder . * * @see com.dremio.exec.proto.UserBitShared.DremioPBError.ErrorType#DATA_WRITE * @return user exception builder */ public static Builder dataWriteError() { return dataWriteError(null); }