Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1880134: Improve exception message when getting query metadata #2059

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/net/snowflake/client/core/SFSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ private JsonNode getQueryMetadata(String queryID) throws SQLException {
queryID,
this,
e.getMessage(),
"No response or invalid response from GET request. Error: {}");
"No response or invalid response from GET request. Error: " + e.getMessage(),
e);
}

// Get response as JSON and parse it to get the query status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.snowflake.client.core.ObjectMapperFactory;
import net.snowflake.client.core.SFBaseSession;
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.SFSession;
import net.snowflake.client.jdbc.telemetry.Telemetry;
import net.snowflake.client.jdbc.telemetry.TelemetryField;
import net.snowflake.client.jdbc.telemetry.TelemetryUtil;
Expand All @@ -41,6 +42,13 @@ public class SnowflakeSQLLoggedException extends SnowflakeSQLException {
private static final SFLogger logger =
SFLoggerFactory.getLogger(SnowflakeSQLLoggedException.class);
private static final ObjectMapper mapper = ObjectMapperFactory.getObjectMapper();
private static final int NO_VENDOR_CODE = -1;

public SnowflakeSQLLoggedException(
String queryID, SFSession session, String sqlState, String message, Exception cause) {
super(queryID, cause, sqlState, NO_VENDOR_CODE, message);
sendTelemetryData(queryID, sqlState, NO_VENDOR_CODE, session, this);
}

/**
* Function to create a TelemetryEvent log from the JSONObject and exception and send it via OOB
Expand Down Expand Up @@ -134,7 +142,7 @@ static JSONObject createOOBValue(String queryId, String SQLState, int vendorCode
if (!Strings.isNullOrEmpty(SQLState)) {
oobValue.put("SQLState", SQLState);
}
if (vendorCode != -1) {
if (vendorCode != NO_VENDOR_CODE) {
oobValue.put("ErrorNumber", vendorCode);
}
return oobValue;
Expand All @@ -159,7 +167,7 @@ static ObjectNode createIBValue(String queryId, String SQLState, int vendorCode)
if (!Strings.isNullOrEmpty(SQLState)) {
ibValue.put("SQLState", SQLState);
}
if (vendorCode != -1) {
if (vendorCode != NO_VENDOR_CODE) {
ibValue.put("ErrorNumber", vendorCode);
}
return ibValue;
Expand Down Expand Up @@ -281,7 +289,7 @@ public SnowflakeSQLLoggedException(SFBaseSession session, String SQLState, Strin
public SnowflakeSQLLoggedException(
String queryId, SFBaseSession session, String SQLState, String reason) {
super(reason, SQLState);
sendTelemetryData(queryId, SQLState, -1, session, this);
sendTelemetryData(queryId, SQLState, NO_VENDOR_CODE, session, this);
}

/**
Expand Down Expand Up @@ -374,7 +382,7 @@ public SnowflakeSQLLoggedException(SFBaseSession session, ErrorCode errorCode, O
public SnowflakeSQLLoggedException(
String queryId, SFBaseSession session, ErrorCode errorCode, Object... params) {
super(queryId, errorCode, params);
sendTelemetryData(queryId, null, -1, session, this);
sendTelemetryData(queryId, null, NO_VENDOR_CODE, session, this);
}

/**
Expand All @@ -383,7 +391,7 @@ public SnowflakeSQLLoggedException(
*/
public SnowflakeSQLLoggedException(SFBaseSession session, SFException e) {
super(e);
sendTelemetryData(null, null, -1, session, this);
sendTelemetryData(null, null, NO_VENDOR_CODE, session, this);
}

/**
Expand All @@ -405,6 +413,6 @@ public SnowflakeSQLLoggedException(SFBaseSession session, String reason) {
*/
public SnowflakeSQLLoggedException(String queryId, SFBaseSession session, String reason) {
super(queryId, reason, null);
sendTelemetryData(queryId, null, -1, session, this);
sendTelemetryData(queryId, null, NO_VENDOR_CODE, session, this);
}
}
Loading