software.amazon.awssdk.services.athena.model.AthenaError Maven / Gradle / Ivy
Show all versions of athena Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.athena.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Provides information about an Athena query error. The AthenaError
feature provides standardized error
* information to help you understand failed queries and take steps after a query failure occurs.
* AthenaError
includes an ErrorCategory
field that specifies whether the cause of the failed
* query is due to system error, user error, or other error.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AthenaError implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ERROR_CATEGORY_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ErrorCategory").getter(getter(AthenaError::errorCategory)).setter(setter(Builder::errorCategory))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ErrorCategory").build()).build();
private static final SdkField ERROR_TYPE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ErrorType").getter(getter(AthenaError::errorType)).setter(setter(Builder::errorType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ErrorType").build()).build();
private static final SdkField RETRYABLE_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("Retryable").getter(getter(AthenaError::retryable)).setter(setter(Builder::retryable))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Retryable").build()).build();
private static final SdkField ERROR_MESSAGE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ErrorMessage").getter(getter(AthenaError::errorMessage)).setter(setter(Builder::errorMessage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ErrorMessage").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ERROR_CATEGORY_FIELD,
ERROR_TYPE_FIELD, RETRYABLE_FIELD, ERROR_MESSAGE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("ErrorCategory", ERROR_CATEGORY_FIELD);
put("ErrorType", ERROR_TYPE_FIELD);
put("Retryable", RETRYABLE_FIELD);
put("ErrorMessage", ERROR_MESSAGE_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final Integer errorCategory;
private final Integer errorType;
private final Boolean retryable;
private final String errorMessage;
private AthenaError(BuilderImpl builder) {
this.errorCategory = builder.errorCategory;
this.errorType = builder.errorType;
this.retryable = builder.retryable;
this.errorMessage = builder.errorMessage;
}
/**
*
* An integer value that specifies the category of a query failure error. The following list shows the category for
* each integer value.
*
*
* 1 - System
*
*
* 2 - User
*
*
* 3 - Other
*
*
* @return An integer value that specifies the category of a query failure error. The following list shows the
* category for each integer value.
*
* 1 - System
*
*
* 2 - User
*
*
* 3 - Other
*/
public final Integer errorCategory() {
return errorCategory;
}
/**
*
* An integer value that provides specific information about an Athena query error. For the meaning of specific
* values, see the Error Type Reference in the Amazon Athena User Guide.
*
*
* @return An integer value that provides specific information about an Athena query error. For the meaning of
* specific values, see the Error Type Reference in the Amazon Athena User Guide.
*/
public final Integer errorType() {
return errorType;
}
/**
*
* True if the query might succeed if resubmitted.
*
*
* @return True if the query might succeed if resubmitted.
*/
public final Boolean retryable() {
return retryable;
}
/**
*
* Contains a short description of the error that occurred.
*
*
* @return Contains a short description of the error that occurred.
*/
public final String errorMessage() {
return errorMessage;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(errorCategory());
hashCode = 31 * hashCode + Objects.hashCode(errorType());
hashCode = 31 * hashCode + Objects.hashCode(retryable());
hashCode = 31 * hashCode + Objects.hashCode(errorMessage());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AthenaError)) {
return false;
}
AthenaError other = (AthenaError) obj;
return Objects.equals(errorCategory(), other.errorCategory()) && Objects.equals(errorType(), other.errorType())
&& Objects.equals(retryable(), other.retryable()) && Objects.equals(errorMessage(), other.errorMessage());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("AthenaError").add("ErrorCategory", errorCategory()).add("ErrorType", errorType())
.add("Retryable", retryable()).add("ErrorMessage", errorMessage()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ErrorCategory":
return Optional.ofNullable(clazz.cast(errorCategory()));
case "ErrorType":
return Optional.ofNullable(clazz.cast(errorType()));
case "Retryable":
return Optional.ofNullable(clazz.cast(retryable()));
case "ErrorMessage":
return Optional.ofNullable(clazz.cast(errorMessage()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function