Skip to content

Commit

Permalink
Add errorName and errorType to QueryError
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Apr 17, 2015
1 parent 1559bcf commit 3527a1c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
Expand Up @@ -28,6 +28,8 @@ public class QueryError
private final String message; private final String message;
private final String sqlState; private final String sqlState;
private final int errorCode; private final int errorCode;
private final String errorName;
private final String errorType;
private final ErrorLocation errorLocation; private final ErrorLocation errorLocation;
private final FailureInfo failureInfo; private final FailureInfo failureInfo;


Expand All @@ -36,12 +38,16 @@ public QueryError(
@JsonProperty("message") String message, @JsonProperty("message") String message,
@JsonProperty("sqlState") String sqlState, @JsonProperty("sqlState") String sqlState,
@JsonProperty("errorCode") int errorCode, @JsonProperty("errorCode") int errorCode,
@JsonProperty("errorName") String errorName,
@JsonProperty("errorType") String errorType,
@JsonProperty("errorLocation") ErrorLocation errorLocation, @JsonProperty("errorLocation") ErrorLocation errorLocation,
@JsonProperty("failureInfo") FailureInfo failureInfo) @JsonProperty("failureInfo") FailureInfo failureInfo)
{ {
this.message = message; this.message = message;
this.sqlState = sqlState; this.sqlState = sqlState;
this.errorCode = errorCode; this.errorCode = errorCode;
this.errorName = errorName;
this.errorType = errorType;
this.errorLocation = errorLocation; this.errorLocation = errorLocation;
this.failureInfo = failureInfo; this.failureInfo = failureInfo;
} }
Expand All @@ -66,6 +72,20 @@ public int getErrorCode()
return errorCode; return errorCode;
} }


@NotNull
@JsonProperty
public String getErrorName()
{
return errorName;
}

@NotNull
@JsonProperty
public String getErrorType()
{
return errorType;
}

@Nullable @Nullable
@JsonProperty @JsonProperty
public ErrorLocation getErrorLocation() public ErrorLocation getErrorLocation()
Expand All @@ -87,6 +107,8 @@ public String toString()
.add("message", message) .add("message", message)
.add("sqlState", sqlState) .add("sqlState", sqlState)
.add("errorCode", errorCode) .add("errorCode", errorCode)
.add("errorName", errorName)
.add("errorType", errorType)
.add("errorLocation", errorLocation) .add("errorLocation", errorLocation)
.add("failureInfo", failureInfo) .add("failureInfo", failureInfo)
.toString(); .toString();
Expand Down
Expand Up @@ -34,6 +34,7 @@
import com.facebook.presto.execution.TaskInfo; import com.facebook.presto.execution.TaskInfo;
import com.facebook.presto.operator.ExchangeClient; import com.facebook.presto.operator.ExchangeClient;
import com.facebook.presto.spi.ConnectorSession; import com.facebook.presto.spi.ConnectorSession;
import com.facebook.presto.spi.ErrorCode;
import com.facebook.presto.spi.Page; import com.facebook.presto.spi.Page;
import com.facebook.presto.spi.block.Block; import com.facebook.presto.spi.block.Block;
import com.facebook.presto.spi.type.StandardTypes; import com.facebook.presto.spi.type.StandardTypes;
Expand Down Expand Up @@ -92,6 +93,7 @@
import static com.facebook.presto.server.ResourceUtil.assertRequest; import static com.facebook.presto.server.ResourceUtil.assertRequest;
import static com.facebook.presto.server.ResourceUtil.createSessionForRequest; import static com.facebook.presto.server.ResourceUtil.createSessionForRequest;
import static com.facebook.presto.spi.StandardErrorCode.INTERNAL_ERROR; import static com.facebook.presto.spi.StandardErrorCode.INTERNAL_ERROR;
import static com.facebook.presto.spi.StandardErrorCode.toErrorType;
import static com.facebook.presto.util.Failures.toFailure; import static com.facebook.presto.util.Failures.toFailure;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
Expand Down Expand Up @@ -624,15 +626,23 @@ private static QueryError toQueryError(QueryInfo queryInfo)
log.warn("Query %s in state %s has no failure info", queryInfo.getQueryId(), state); log.warn("Query %s in state %s has no failure info", queryInfo.getQueryId(), state);
failure = toFailure(new RuntimeException(format("Query is %s (reason unknown)", state))).toFailureInfo(); failure = toFailure(new RuntimeException(format("Query is %s (reason unknown)", state))).toFailureInfo();
} }
int errorCode;
ErrorCode errorCode;
if (queryInfo.getErrorCode() != null) { if (queryInfo.getErrorCode() != null) {
errorCode = queryInfo.getErrorCode().getCode(); errorCode = queryInfo.getErrorCode();
} }
else { else {
errorCode = INTERNAL_ERROR.toErrorCode().getCode(); errorCode = INTERNAL_ERROR.toErrorCode();
log.warn("Failed query %s has no error code", queryInfo.getQueryId()); log.warn("Failed query %s has no error code", queryInfo.getQueryId());
} }
return new QueryError(failure.getMessage(), null, errorCode, failure.getErrorLocation(), failure); return new QueryError(
failure.getMessage(),
null,
errorCode.getCode(),
errorCode.getName(),
toErrorType(errorCode.getCode()).toString(),
failure.getErrorLocation(),
failure);
} }


private static class RowIterable private static class RowIterable
Expand Down

0 comments on commit 3527a1c

Please sign in to comment.