Commit 89a38727 by Madhan Neethiraj

ATLAS-1611: incorrect error code for negative tests (#2)

parent de7ae290
...@@ -67,6 +67,7 @@ public enum AtlasErrorCode { ...@@ -67,6 +67,7 @@ public enum AtlasErrorCode {
INSTANCE_LINEAGE_INVALID_PARAMS(400, "ATLAS-400-00-026", "Invalid lineage query parameters passed {0}: {1}"), INSTANCE_LINEAGE_INVALID_PARAMS(400, "ATLAS-400-00-026", "Invalid lineage query parameters passed {0}: {1}"),
ATTRIBUTE_UPDATE_NOT_SUPPORTED(400, "ATLAS-400-00-027", "{0}.{1} : attribute update not supported"), ATTRIBUTE_UPDATE_NOT_SUPPORTED(400, "ATLAS-400-00-027", "{0}.{1} : attribute update not supported"),
INVALID_VALUE(400, "ATLAS-400-00-028", "invalid value: {0}"), INVALID_VALUE(400, "ATLAS-400-00-028", "invalid value: {0}"),
BAD_REQUEST(400, "ATLAS-400-00-020", "{0}"),
// All Not found enums go here // All Not found enums go here
TYPE_NAME_NOT_FOUND(404, "ATLAS-404-00-001", "Given typename {0} was invalid"), TYPE_NAME_NOT_FOUND(404, "ATLAS-404-00-001", "Given typename {0} was invalid"),
...@@ -78,11 +79,12 @@ public enum AtlasErrorCode { ...@@ -78,11 +79,12 @@ public enum AtlasErrorCode {
CLASSIFICATION_NOT_FOUND(404, "ATLAS-404-00-008", "Given classification {0} was invalid"), CLASSIFICATION_NOT_FOUND(404, "ATLAS-404-00-008", "Given classification {0} was invalid"),
INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND(404, "ATLAS-404-00-009", "Instance {0} with unique attribute {1} does not exist"), INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND(404, "ATLAS-404-00-009", "Instance {0} with unique attribute {1} does not exist"),
REFERENCED_ENTITY_NOT_FOUND(404, "ATLAS-404-00-00A", "Referenced entity {0} is not found"), REFERENCED_ENTITY_NOT_FOUND(404, "ATLAS-404-00-00A", "Referenced entity {0} is not found"),
INSTANCE_NOT_FOUND(404, "ATLAS-404-00-00B", "Given instance is invalid/not found: {0}"),
// All data conflict errors go here // All data conflict errors go here
TYPE_ALREADY_EXISTS(409, "ATLAS-409-00-001", "Given type {0} already exists"), TYPE_ALREADY_EXISTS(409, "ATLAS-409-00-001", "Given type {0} already exists"),
TYPE_HAS_REFERENCES(409, "ATLAS-409-00-002", "Given type {0} has references"), TYPE_HAS_REFERENCES(409, "ATLAS-409-00-002", "Given type {0} has references"),
INSTANCE_ALREADY_EXISTS(409, "ATLAS-409-00-003", "Given entity {0} already exists"), INSTANCE_ALREADY_EXISTS(409, "ATLAS-409-00-003", "failed to update entity: {0}"),
// All internal errors go here // All internal errors go here
INTERNAL_ERROR(500, "ATLAS-500-00-001", "Internal server error {0}"), INTERNAL_ERROR(500, "ATLAS-500-00-001", "Internal server error {0}"),
......
...@@ -45,6 +45,7 @@ import org.apache.atlas.typesystem.ITypedReferenceableInstance; ...@@ -45,6 +45,7 @@ import org.apache.atlas.typesystem.ITypedReferenceableInstance;
import org.apache.atlas.typesystem.ITypedStruct; import org.apache.atlas.typesystem.ITypedStruct;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.Struct; import org.apache.atlas.typesystem.Struct;
import org.apache.atlas.typesystem.exception.EntityExistsException;
import org.apache.atlas.typesystem.exception.EntityNotFoundException; import org.apache.atlas.typesystem.exception.EntityNotFoundException;
import org.apache.atlas.typesystem.exception.TraitNotFoundException; import org.apache.atlas.typesystem.exception.TraitNotFoundException;
import org.apache.atlas.typesystem.exception.TypeNotFoundException; import org.apache.atlas.typesystem.exception.TypeNotFoundException;
...@@ -199,19 +200,23 @@ public class AtlasInstanceConverter { ...@@ -199,19 +200,23 @@ public class AtlasInstanceConverter {
} }
public static AtlasBaseException toAtlasBaseException(AtlasException e) { public static AtlasBaseException toAtlasBaseException(AtlasException e) {
if (e instanceof EntityExistsException) {
return new AtlasBaseException(AtlasErrorCode.INSTANCE_ALREADY_EXISTS, e.getMessage());
}
if ( e instanceof EntityNotFoundException || e instanceof TraitNotFoundException) { if ( e instanceof EntityNotFoundException || e instanceof TraitNotFoundException) {
return new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, e); return new AtlasBaseException(AtlasErrorCode.INSTANCE_NOT_FOUND, e.getMessage());
} }
if ( e instanceof TypeNotFoundException) { if ( e instanceof TypeNotFoundException) {
return new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, e); return new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, e.getMessage());
} }
if (e instanceof ValueConversionException) { if (e instanceof ValueConversionException) {
return new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, e, e.getMessage()); return new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, e, e.getMessage());
} }
return new AtlasBaseException(e); return new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment