final String errMsgFromServer = resp.getError() != null ? resp.getError().getMessage() : "";
@Override public String getSchema() throws SQLException { checkOpen(); try { UserProtos.GetServerMetaResp response = client.getServerMeta().get(); if (response.getStatus() != UserProtos.RequestStatus.OK) { UserBitShared.DrillPBError drillError = response.getError(); throw new SQLException("Error when getting server meta: " + drillError.getMessage()); } UserProtos.ServerMeta serverMeta = response.getServerMeta(); String currentSchema = serverMeta.hasCurrentSchema() ? serverMeta.getCurrentSchema() : null; return StringUtils.isEmpty(currentSchema) ? null : currentSchema; } catch (InterruptedException | ExecutionException e) { throw new SQLException("Error when getting server meta", e); } }
private ServerMeta getServerMeta() throws SQLException { assert getServerMetaSupported(); if (serverMeta == null) { synchronized(this) { if (serverMeta == null) { DrillConnectionImpl connection = (DrillConnectionImpl) getConnection(); try { GetServerMetaResp resp = connection.getClient().getServerMeta().get(); if (resp.getStatus() != RequestStatus.OK) { DrillPBError drillError = resp.getError(); throw new SQLException("Error when getting server meta: " + drillError.getMessage()); } serverMeta = resp.getServerMeta(); convertSupport = SQLConvertSupport.toSQLConvertSupport(serverMeta.getConvertSupportList()); } catch (InterruptedException e) { throw new SQLException("Interrupted when getting server meta", e); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause == null) { throw new AssertionError("Something unknown happened", e); } Throwables.throwIfUnchecked(cause); throw new SQLException("Error when getting server meta", cause); } } } } return serverMeta; }
final String errMsgFromServer = resp.getError() != null ? resp.getError().getMessage() : "";
throw new DrillRuntimeException(new SQLException("Failure getting metadata: " + error.getMessage()));
private ServerMeta getServerMeta() throws SQLException { assert getServerMetaSupported(); if (serverMeta == null) { synchronized(this) { if (serverMeta == null) { DrillConnectionImpl connection = (DrillConnectionImpl) getConnection(); try { GetServerMetaResp resp = connection.getClient().getServerMeta().get(); if (resp.getStatus() != RequestStatus.OK) { DrillPBError drillError = resp.getError(); throw new SQLException("Error when getting server meta: " + drillError.getMessage()); } serverMeta = resp.getServerMeta(); convertSupport = SQLConvertSupport.toSQLConvertSupport(serverMeta.getConvertSupportList()); } catch (InterruptedException e) { throw new SQLException("Interrupted when getting server meta", e); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause == null) { throw new AssertionError("Something unknown happened", e); } Throwables.throwIfUnchecked(cause); throw new SQLException("Error when getting server meta", cause); } } } } return serverMeta; }
public void writeTo(com.dyuproject.protostuff.Output output, org.apache.drill.exec.proto.UserBitShared.DrillPBError message) throws java.io.IOException { if(message.hasErrorId()) output.writeString(1, message.getErrorId(), false); if(message.hasEndpoint()) output.writeObject(2, message.getEndpoint(), org.apache.drill.exec.proto.SchemaCoordinationProtos.DrillbitEndpoint.WRITE, false); if(message.hasErrorType()) output.writeEnum(3, message.getErrorType().getNumber(), false); if(message.hasMessage()) output.writeString(4, message.getMessage(), false); if(message.hasException()) output.writeObject(5, message.getException(), org.apache.drill.exec.proto.SchemaUserBitShared.ExceptionWrapper.WRITE, false); for(org.apache.drill.exec.proto.UserBitShared.ParsingError parsingError : message.getParsingErrorList()) output.writeObject(6, parsingError, org.apache.drill.exec.proto.SchemaUserBitShared.ParsingError.WRITE, true); } public boolean isInitialized(org.apache.drill.exec.proto.UserBitShared.DrillPBError message)
@Override public String getMessage() { return error.getMessage(); // we don't want super class to generate the error message }
/** * <code>optional string message = 4;</code> */ public Builder clearMessage() { bitField0_ = (bitField0_ & ~0x00000008); message_ = getDefaultInstance().getMessage(); onChanged(); return this; } /**
throw new DrillRuntimeException(new SQLException("Failure getting metadata: " + error.getMessage()));
public void writeTo(com.dyuproject.protostuff.Output output, org.apache.drill.exec.proto.UserBitShared.DrillPBError message) throws java.io.IOException { if(message.hasErrorId()) output.writeString(1, message.getErrorId(), false); if(message.hasEndpoint()) output.writeObject(2, message.getEndpoint(), org.apache.drill.exec.proto.SchemaCoordinationProtos.DrillbitEndpoint.WRITE, false); if(message.hasErrorType()) output.writeEnum(3, message.getErrorType().getNumber(), false); if(message.hasMessage()) output.writeString(4, message.getMessage(), false); if(message.hasException()) output.writeObject(5, message.getException(), org.apache.drill.exec.proto.SchemaUserBitShared.ExceptionWrapper.WRITE, false); for(org.apache.drill.exec.proto.UserBitShared.ParsingError parsingError : message.getParsingErrorList()) output.writeObject(6, parsingError, org.apache.drill.exec.proto.SchemaUserBitShared.ParsingError.WRITE, true); } public boolean isInitialized(org.apache.drill.exec.proto.UserBitShared.DrillPBError message)
@Override public String getMessage() { return error.getMessage(); // we don't want super class to generate the error message }
@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); DrillPBError error = uex.getOrCreatePBError(false); Assert.assertEquals(messageA, uex.getOriginalMessage()); Assert.assertFalse(error.getMessage().contains(messageB)); // messageB should not be part of the context }
@Test public void testBuildUserExceptionWithCauseAndMessage() { String messageA = "Test message A"; String messageB = "Test message B"; UserException uex = UserException.dataWriteError(new RuntimeException(messageA)).message(messageB).build(logger); DrillPBError error = uex.getOrCreatePBError(false); // passed message should override the cause message Assert.assertEquals(ErrorType.DATA_WRITE, error.getErrorType()); Assert.assertFalse(error.getMessage().contains(messageA)); // messageA should not be part of the context Assert.assertEquals(messageB, uex.getOriginalMessage()); }
/** * <code>optional string message = 4;</code> */ public Builder clearMessage() { bitField0_ = (bitField0_ & ~0x00000008); message_ = getDefaultInstance().getMessage(); onChanged(); return this; } /**