atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [3/3] incubator-atlas git commit: ATLAS-1611: incorrect error code for negative tests (#2)
Date Fri, 17 Mar 2017 07:34:24 GMT
ATLAS-1611: incorrect error code for negative tests (#2)


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/89a38727
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/89a38727
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/89a38727

Branch: refs/heads/master
Commit: 89a387279d9d0cae66f8e0a75a9ee3610da8c173
Parents: de7ae29
Author: Madhan Neethiraj <madhan@apache.org>
Authored: Fri Mar 10 14:36:14 2017 -0800
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Fri Mar 17 00:13:26 2017 -0700

----------------------------------------------------------------------
 intg/src/main/java/org/apache/atlas/AtlasErrorCode.java  |  4 +++-
 .../repository/converters/AtlasInstanceConverter.java    | 11 ++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/89a38727/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
index 69c201d..5054cf0 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
@@ -67,6 +67,7 @@ public enum AtlasErrorCode {
     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"),
 	INVALID_VALUE(400, "ATLAS-400-00-028", "invalid value: {0}"),
+    BAD_REQUEST(400, "ATLAS-400-00-020", "{0}"),
 
      // All Not found enums go here
     TYPE_NAME_NOT_FOUND(404, "ATLAS-404-00-001", "Given typename {0} was invalid"),
@@ -78,11 +79,12 @@ public enum AtlasErrorCode {
     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"),
     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
     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"),
-    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
     INTERNAL_ERROR(500, "ATLAS-500-00-001", "Internal server error {0}"),

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/89a38727/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
index a4f99a5..6e0766d 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
@@ -45,6 +45,7 @@ import org.apache.atlas.typesystem.ITypedReferenceableInstance;
 import org.apache.atlas.typesystem.ITypedStruct;
 import org.apache.atlas.typesystem.Referenceable;
 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.TraitNotFoundException;
 import org.apache.atlas.typesystem.exception.TypeNotFoundException;
@@ -199,19 +200,23 @@ public class AtlasInstanceConverter {
     }
 
     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)
{
-            return new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, e);
+            return new AtlasBaseException(AtlasErrorCode.INSTANCE_NOT_FOUND, e.getMessage());
         }
 
         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) {
             return new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, e, e.getMessage());
         }
 
-        return new AtlasBaseException(e);
+        return new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage());
     }
 
 


Mime
View raw message