atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From suma...@apache.org
Subject incubator-atlas git commit: ATLAS-1200 Error Catalog enhancement (apoorvnaik via sumasai)
Date Mon, 24 Oct 2016 22:23:14 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master 5a4dd2e72 -> fdf97ae4d


ATLAS-1200 Error Catalog enhancement (apoorvnaik via sumasai)


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

Branch: refs/heads/master
Commit: fdf97ae4d0caf4b10c8f3f6562132a0cdac76c38
Parents: 5a4dd2e
Author: Suma Shivaprasad <sumasai.shivaprasad@gmail.com>
Authored: Mon Oct 24 15:22:48 2016 -0700
Committer: Suma Shivaprasad <sumasai.shivaprasad@gmail.com>
Committed: Mon Oct 24 15:22:48 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/atlas/AtlasConstants.java   |   1 -
 .../java/org/apache/atlas/AtlasErrorCode.java   |  76 ++++++++
 .../atlas/exception/AtlasBaseException.java     |  20 +++
 .../atlas/model/typedef/AtlasTypesDef.java      |   8 +
 release-log.txt                                 |   1 +
 .../store/graph/AtlasTypeDefGraphStore.java     |  80 ++++++---
 .../graph/v1/AtlasClassificationDefStoreV1.java |  36 ++--
 .../store/graph/v1/AtlasEntityDefStoreV1.java   |  21 +--
 .../store/graph/v1/AtlasEnumDefStoreV1.java     |  15 +-
 .../store/graph/v1/AtlasStructDefStoreV1.java   |  23 +--
 .../graph/v1/AtlasTypeDefGraphStoreV1.java      |   4 +-
 .../atlas/web/errors/AllExceptionMapper.java    |  51 ++++++
 .../web/errors/AtlasBaseExceptionMapper.java    |  82 +++++++++
 .../atlas/web/errors/ExceptionMapperUtil.java   |  41 +++++
 .../web/errors/LoggingExceptionMapper.java      |  60 -------
 .../org/apache/atlas/web/rest/TypesREST.java    | 176 ++++++-------------
 webapp/src/main/webapp/WEB-INF/web.xml          |   2 +-
 17 files changed, 449 insertions(+), 248 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/common/src/main/java/org/apache/atlas/AtlasConstants.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/atlas/AtlasConstants.java b/common/src/main/java/org/apache/atlas/AtlasConstants.java
index 8521f63..f5de1df 100644
--- a/common/src/main/java/org/apache/atlas/AtlasConstants.java
+++ b/common/src/main/java/org/apache/atlas/AtlasConstants.java
@@ -34,5 +34,4 @@ public final class AtlasConstants {
     public static final String DEFAULT_ATLAS_REST_ADDRESS = "http://localhost:21000";
     public static final int ATLAS_SHUTDOWN_HOOK_PRIORITY = 30;
     public static final String DEFAULT_TYPE_VERSION = "1.0";
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/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
new file mode 100644
index 0000000..ce68e6e
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License 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 org.apache.atlas;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.MessageFormat;
+import java.util.Arrays;
+
+import javax.ws.rs.core.Response;
+
+public enum AtlasErrorCode {
+    NO_SEARCH_RESULTS(204, "ATLAS2041E", "Given search filter did not yield any results"),
+
+    UNKNOWN_TYPE(400, "ATLAS4001E", "Unknown type {0} for {1}.{2}"),
+    TYPE_NAME_NOT_FOUND(404, "ATLAS4041E", "Given typename {0} was invalid"),
+    TYPE_GUID_NOT_FOUND(404, "ATLAS4042E", "Given type guid {0} was invalid"),
+    EMPTY_RESULTS(404, "ATLAS4044E", "No result found for {0}"),
+
+    TYPE_ALREADY_EXISTS(409, "ATLAS4091E", "Given type {0} already exists"),
+    TYPE_HAS_REFERENCES(409, "ATLAS4092E", "Given type {0} has references"),
+    TYPE_MATCH_FAILED(409, "ATLAS4093E", "Given type {0} doesn't match {1}"),
+
+    INTERNAL_ERROR(500, "ATLAS5001E", "Internal server error {0}");
+
+    private String errorCode;
+    private String errorMessage;
+    private Response.Status httpCode;
+
+    private static final Logger LOG = LoggerFactory.getLogger(AtlasErrorCode.class);
+
+    AtlasErrorCode(int httpCode, String errorCode, String errorMessage) {
+        this.httpCode = Response.Status.fromStatusCode(httpCode);
+        this.errorCode = errorCode;
+        this.errorMessage = errorMessage;
+
+    }
+
+    public String getFormattedErrorMessage(String... params) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(String.format("<== AtlasErrorCode.getMessage(%s)", Arrays.toString(params)));
+        }
+
+        MessageFormat mf = new MessageFormat(errorMessage);
+        String result = mf.format(params);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(String.format("==> AtlasErrorCode.getMessage(%s): %s", Arrays.toString(params), result));
+        }
+        return result;
+    }
+
+    public Response.Status getHttpCode() {
+        return httpCode;
+    }
+
+    public String getErrorCode() {
+        return errorCode;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/intg/src/main/java/org/apache/atlas/exception/AtlasBaseException.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/exception/AtlasBaseException.java b/intg/src/main/java/org/apache/atlas/exception/AtlasBaseException.java
index 3538f41..d26ec0e 100644
--- a/intg/src/main/java/org/apache/atlas/exception/AtlasBaseException.java
+++ b/intg/src/main/java/org/apache/atlas/exception/AtlasBaseException.java
@@ -17,27 +17,47 @@
  */
 package org.apache.atlas.exception;
 
+import org.apache.atlas.AtlasErrorCode;
+
+import javax.ws.rs.core.Response;
+
 /**
  * Base Exception class for Atlas API.
  */
 public class AtlasBaseException extends Exception {
 
+    private AtlasErrorCode atlasErrorCode;
+
+    public AtlasBaseException(AtlasErrorCode errorCode, String ... params) {
+        super(errorCode.getFormattedErrorMessage(params));
+        this.atlasErrorCode = errorCode;
+    }
+
     public AtlasBaseException() {
+        this(AtlasErrorCode.INTERNAL_ERROR);
     }
 
     public AtlasBaseException(String message) {
         super(message);
+        this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR;
     }
 
     public AtlasBaseException(String message, Throwable cause) {
         super(message, cause);
+        this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR;
     }
 
     public AtlasBaseException(Throwable cause) {
         super(cause);
+        this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR;
     }
 
     public AtlasBaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
         super(message, cause, enableSuppression, writableStackTrace);
+        this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR;
+    }
+
+    public AtlasErrorCode getAtlasErrorCode() {
+        return atlasErrorCode;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/intg/src/main/java/org/apache/atlas/model/typedef/AtlasTypesDef.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasTypesDef.java b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasTypesDef.java
index 5d3f4a3..fb2029d 100644
--- a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasTypesDef.java
+++ b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasTypesDef.java
@@ -17,6 +17,7 @@
  */
 package org.apache.atlas.model.typedef;
 
+import org.apache.commons.collections.CollectionUtils;
 import org.codehaus.jackson.annotate.JsonAutoDetect;
 import org.codehaus.jackson.annotate.JsonIgnoreProperties;
 import org.codehaus.jackson.map.annotate.JsonSerialize;
@@ -89,4 +90,11 @@ public class AtlasTypesDef {
     public void setEntityDefs(List<AtlasEntityDef> entityDefs) {
         this.entityDefs = entityDefs;
     }
+
+    public boolean isEmpty() {
+        return CollectionUtils.isEmpty(enumDefs) &&
+                CollectionUtils.isEmpty(structDefs) &&
+                CollectionUtils.isEmpty(classificationDefs) &&
+                CollectionUtils.isEmpty(entityDefs);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 56ef736..9d29bb9 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
 ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
 
 ALL CHANGES:
+ATLAS-1200 Error Catalog enhancement (apoorvnaik via sumasai)
 ATLAS-1207 Dataset exists query in lineage APIs takes longer (shwethags)
 ATLAS-1232 added preCreate(), preDelete() in typedef persistence, to enable edge creation for references in a later stage (mneethiraj)
 ATLAS-1183 UI: help link should point to atlas website (kevalbhatt via shwethags)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
index 1aca5eb..ebc7ab2 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
@@ -17,6 +17,7 @@
  */
 package org.apache.atlas.repository.store.graph;
 
+import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.GraphTransaction;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.SearchFilter;
@@ -41,6 +42,7 @@ import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 
@@ -102,9 +104,8 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         Collection<AtlasEnumDef> enumDefs = typeRegistry.getAllEnumDefs();
 
-        if (enumDefs != null) {
-            ret = new ArrayList<>(enumDefs);
-        }
+        ret = CollectionUtils.isNotEmpty(enumDefs) ?
+                new ArrayList<>(enumDefs) : Collections.<AtlasEnumDef>emptyList();
 
         return ret;
     }
@@ -113,7 +114,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public AtlasEnumDef getEnumDefByName(String name) throws AtlasBaseException {
         AtlasEnumDef ret = typeRegistry.getEnumDefByName(name);
-
+        if (ret == null) {
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
+        }
         return ret;
     }
 
@@ -121,7 +124,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public AtlasEnumDef getEnumDefByGuid(String guid) throws AtlasBaseException {
         AtlasEnumDef ret = typeRegistry.getEnumDefByGuid(guid);
-
+        if (ret == null) {
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
+        }
         return ret;
     }
 
@@ -180,7 +185,11 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasEnumDefs searchEnumDefs(SearchFilter filter) throws AtlasBaseException {
-        return getEnumDefStore(typeRegistry).search(filter);
+        AtlasEnumDefs search = getEnumDefStore(typeRegistry).search(filter);
+        if (search == null || search.getTotalCount() == 0) {
+            throw new AtlasBaseException(AtlasErrorCode.NO_SEARCH_RESULTS);
+        }
+        return search;
     }
 
     @Override
@@ -206,9 +215,8 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         Collection<AtlasStructDef> structDefs = typeRegistry.getAllStructDefs();
 
-        if (structDefs != null) {
-            ret = new ArrayList<>(structDefs);
-        }
+        ret = CollectionUtils.isNotEmpty(structDefs) ?
+                new ArrayList<>(structDefs) : Collections.<AtlasStructDef>emptyList();
 
         return ret;
     }
@@ -217,7 +225,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public AtlasStructDef getStructDefByName(String name) throws AtlasBaseException {
         AtlasStructDef ret = typeRegistry.getStructDefByName(name);
-
+        if (ret == null) {
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
+        }
         return ret;
     }
 
@@ -225,7 +235,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public AtlasStructDef getStructDefByGuid(String guid) throws AtlasBaseException {
         AtlasStructDef ret = typeRegistry.getStructDefByGuid(guid);
-
+        if (ret == null) {
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
+        }
         return ret;
     }
 
@@ -284,7 +296,11 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasStructDefs searchStructDefs(SearchFilter filter) throws AtlasBaseException {
-        return getStructDefStore(typeRegistry).search(filter);
+        AtlasStructDefs search = getStructDefStore(typeRegistry).search(filter);
+        if (search == null || search.getTotalCount() == 0) {
+            throw new AtlasBaseException(AtlasErrorCode.NO_SEARCH_RESULTS);
+        }
+        return search;
     }
 
     @Override
@@ -311,9 +327,8 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         Collection<AtlasClassificationDef> classificationDefs = typeRegistry.getAllClassificationDefs();
 
-        if (classificationDefs != null) {
-            ret = new ArrayList<>(classificationDefs);
-        }
+        ret = CollectionUtils.isNotEmpty(classificationDefs) ?
+                new ArrayList<>(classificationDefs) : Collections.<AtlasClassificationDef>emptyList();
 
         return ret;
     }
@@ -323,6 +338,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     public AtlasClassificationDef getClassificationDefByName(String name) throws AtlasBaseException {
         AtlasClassificationDef ret = typeRegistry.getClassificationDefByName(name);
 
+        if (ret == null) {
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
+        }
         return ret;
     }
 
@@ -330,7 +348,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public AtlasClassificationDef getClassificationDefByGuid(String guid) throws AtlasBaseException {
         AtlasClassificationDef ret = typeRegistry.getClassificationDefByGuid(guid);
-
+        if (ret == null) {
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
+        }
         return ret;
     }
 
@@ -391,7 +411,11 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasClassificationDefs searchClassificationDefs(SearchFilter filter) throws AtlasBaseException {
-        return getClassificationDefStore(typeRegistry).search(filter);
+        AtlasClassificationDefs search = getClassificationDefStore(typeRegistry).search(filter);
+        if (search == null || search.getTotalCount() == 0) {
+            throw new AtlasBaseException(AtlasErrorCode.NO_SEARCH_RESULTS);
+        }
+        return search;
     }
 
     @Override
@@ -417,9 +441,8 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
         Collection<AtlasEntityDef> entityDefs = typeRegistry.getAllEntityDefs();
 
-        if (entityDefs != null) {
-            ret = new ArrayList<>(entityDefs);
-        }
+        ret = CollectionUtils.isNotEmpty(entityDefs) ?
+                new ArrayList<>(entityDefs) : Collections.<AtlasEntityDef>emptyList();
 
         return ret;
     }
@@ -428,7 +451,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public AtlasEntityDef getEntityDefByName(String name) throws AtlasBaseException {
         AtlasEntityDef ret = typeRegistry.getEntityDefByName(name);
-
+        if (ret == null) {
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
+        }
         return ret;
     }
 
@@ -436,7 +461,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public AtlasEntityDef getEntityDefByGuid(String guid) throws AtlasBaseException {
         AtlasEntityDef ret = typeRegistry.getEntityDefByGuid(guid);
-
+        if (ret == null) {
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
+        }
         return ret;
     }
 
@@ -495,7 +522,11 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasEntityDefs searchEntityDefs(SearchFilter filter) throws AtlasBaseException {
-        return getEntityDefStore(typeRegistry).search(filter);
+        AtlasEntityDefs search = getEntityDefStore(typeRegistry).search(filter);
+        if (search == null || search.getTotalCount() == 0) {
+            throw new AtlasBaseException(AtlasErrorCode.NO_SEARCH_RESULTS);
+        }
+        return search;
     }
 
     @Override
@@ -809,6 +840,9 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
             LOG.error("Failed to retrieve the EntityDefs", ex);
         }
 
+        if (typesDef.isEmpty()) {
+            throw new AtlasBaseException(AtlasErrorCode.NO_SEARCH_RESULTS);
+        }
         return typesDef;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
index 1794278..43f93d4 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
@@ -18,6 +18,7 @@
 package org.apache.atlas.repository.store.graph.v1;
 
 
+import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.SearchFilter;
 import org.apache.atlas.model.typedef.AtlasClassificationDef;
@@ -58,13 +59,13 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
         AtlasType type = typeRegistry.getType(classificationDef.getName());
 
         if (type.getTypeCategory() != AtlasType.TypeCategory.CLASSIFICATION) {
-            throw new AtlasBaseException(classificationDef.getName() + ": not a classification type");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name());
         }
 
         AtlasVertex ret = typeDefStore.findTypeVertexByName(classificationDef.getName());
 
         if (ret != null) {
-            throw new AtlasBaseException(classificationDef.getName() + ": type already exists");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, classificationDef.getName());
         }
 
         ret = typeDefStore.createTypeVertex(classificationDef);
@@ -132,7 +133,7 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no classificationDef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, TypeCategory.class);
@@ -155,7 +156,7 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no classificationDef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         AtlasClassificationDef ret = toClassificationDef(vertex);
@@ -193,13 +194,13 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
         AtlasType type = typeRegistry.getType(classificationDef.getName());
 
         if (type.getTypeCategory() != AtlasType.TypeCategory.CLASSIFICATION) {
-            throw new AtlasBaseException(classificationDef.getName() + ": not a struct type");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name());
         }
 
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no classificationDef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         updateVertexPreUpdate(classificationDef, (AtlasClassificationType)type, vertex);
@@ -223,13 +224,13 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
         AtlasType type = typeRegistry.getTypeByGuid(guid);
 
         if (type.getTypeCategory() != AtlasType.TypeCategory.CLASSIFICATION) {
-            throw new AtlasBaseException(classificationDef.getName() + ": not a struct type");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name());
         }
 
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no classificationDef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         updateVertexPreUpdate(classificationDef, (AtlasClassificationType)type, vertex);
@@ -253,7 +254,7 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
         AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT);
 
         if (ret == null) {
-            throw new AtlasBaseException("no classificationDef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         typeDefStore.deleteTypeVertexOutEdges(ret);
@@ -295,7 +296,7 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
         AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
 
         if (ret == null) {
-            throw new AtlasBaseException("no classificationDef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         typeDefStore.deleteTypeVertexOutEdges(ret);
@@ -346,15 +347,18 @@ public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 imple
             }
         }
 
-        CollectionUtils.filter(classificationDefs, FilterUtil.getPredicateFromSearchFilter(filter));
+        if (CollectionUtils.isNotEmpty(classificationDefs)) {
+            CollectionUtils.filter(classificationDefs, FilterUtil.getPredicateFromSearchFilter(filter));
 
-        AtlasClassificationDefs ret = new AtlasClassificationDefs(classificationDefs);
+            AtlasClassificationDefs ret = new AtlasClassificationDefs(classificationDefs);
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasClassificationDefStoreV1.search({}): {}", filter, ret);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasClassificationDefStoreV1.search({}): {}", filter, ret);
+            }
+            return ret;
+        } else {
+            throw new AtlasBaseException(AtlasErrorCode.NO_SEARCH_RESULTS);
         }
-
-        return ret;
     }
 
     private void updateVertexPreCreate(AtlasClassificationDef  classificationDef,

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
index a421006..5babae5 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
@@ -17,6 +17,7 @@
  */
 package org.apache.atlas.repository.store.graph.v1;
 
+import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.SearchFilter;
 import org.apache.atlas.model.typedef.AtlasEntityDef;
@@ -57,13 +58,13 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasType type = typeRegistry.getType(entityDef.getName());
 
         if (type.getTypeCategory() != AtlasType.TypeCategory.ENTITY) {
-            throw new AtlasBaseException(entityDef.getName() + ": not an entity type");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name());
         }
 
         AtlasVertex ret = typeDefStore.findTypeVertexByName(entityDef.getName());
 
         if (ret != null) {
-            throw new AtlasBaseException(entityDef.getName() + ": type already exists");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, entityDef.getName());
         }
 
         ret = typeDefStore.createTypeVertex(entityDef);
@@ -131,7 +132,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no entityDef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, TypeCategory.class);
@@ -154,7 +155,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no entityDef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         AtlasEntityDef ret = toEntityDef(vertex);
@@ -191,13 +192,13 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasType type = typeRegistry.getType(entityDef.getName());
 
         if (type.getTypeCategory() != AtlasType.TypeCategory.ENTITY) {
-            throw new AtlasBaseException(entityDef.getName() + ": not an entity type");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name());
         }
 
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no entityDef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         updateVertexPreUpdate(entityDef, (AtlasEntityType)type, vertex);
@@ -221,13 +222,13 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasType type = typeRegistry.getTypeByGuid(guid);
 
         if (type.getTypeCategory() != AtlasType.TypeCategory.ENTITY) {
-            throw new AtlasBaseException(entityDef.getName() + ": not an entity type");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name());
         }
 
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no entityDef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         updateVertexPreUpdate(entityDef, (AtlasEntityType)type, vertex);
@@ -251,7 +252,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
 
         if (ret == null) {
-            throw new AtlasBaseException("no entityDef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         typeDefStore.deleteTypeVertexOutEdges(ret);
@@ -293,7 +294,7 @@ public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);
 
         if (ret == null) {
-            throw new AtlasBaseException("no entityDef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         typeDefStore.deleteTypeVertexOutEdges(ret);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
index 32ef939..ffa73e2 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
@@ -17,6 +17,7 @@
  */
 package org.apache.atlas.repository.store.graph.v1;
 
+import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.SearchFilter;
 import org.apache.atlas.model.typedef.AtlasEnumDef;
@@ -57,7 +58,7 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
         AtlasVertex vertex = typeDefStore.findTypeVertexByName(enumDef.getName());
 
         if (vertex != null) {
-            throw new AtlasBaseException(enumDef.getName() + ": type already exists");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, enumDef.getName());
         }
 
         vertex = typeDefStore.createTypeVertex(enumDef);
@@ -102,7 +103,7 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.ENUM);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no enumdef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, TypeCategory.class);
@@ -125,7 +126,7 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.ENUM);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no enumdef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         AtlasEnumDef ret = toEnumDef(vertex);
@@ -162,7 +163,7 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.ENUM);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no enumdef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         toVertex(enumDef, vertex);
@@ -185,7 +186,7 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.ENUM);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no enumdef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         toVertex(enumDef, vertex);
@@ -208,7 +209,7 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.ENUM);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no enumdef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         typeDefStore.deleteTypeVertex(vertex);
@@ -227,7 +228,7 @@ public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements Atla
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.ENUM);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no enumdef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         typeDefStore.deleteTypeVertex(vertex);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
index a5c9093..f63adbb 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
@@ -17,6 +17,7 @@
  */
 package org.apache.atlas.repository.store.graph.v1;
 
+import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.SearchFilter;
 import org.apache.atlas.model.typedef.AtlasStructDef;
@@ -70,13 +71,13 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasType type = typeRegistry.getType(structDef.getName());
 
         if (type.getTypeCategory() != AtlasType.TypeCategory.STRUCT) {
-            throw new AtlasBaseException(structDef.getName() + ": not a struct type");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, structDef.getName(), TypeCategory.STRUCT.name());
         }
 
         AtlasVertex ret = typeDefStore.findTypeVertexByName(structDef.getName());
 
         if (ret != null) {
-            throw new AtlasBaseException(structDef.getName() + ": type already exists");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, structDef.getName());
         }
 
         ret = typeDefStore.createTypeVertex(structDef);
@@ -143,7 +144,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no structDef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, String.class);
@@ -166,7 +167,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.STRUCT);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no structDef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         AtlasStructDef ret = toStructDef(vertex);
@@ -203,13 +204,13 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasType type = typeRegistry.getType(structDef.getName());
 
         if (type.getTypeCategory() != AtlasType.TypeCategory.STRUCT) {
-            throw new AtlasBaseException(structDef.getName() + ": not a struct type");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, structDef.getName(), TypeCategory.STRUCT.name());
         }
 
         AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no structDef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         AtlasStructDefStoreV1.updateVertexPreUpdate(structDef, (AtlasStructType)type, vertex, typeDefStore);
@@ -233,13 +234,13 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasType type = typeRegistry.getTypeByGuid(guid);
 
         if (type.getTypeCategory() != AtlasType.TypeCategory.STRUCT) {
-            throw new AtlasBaseException(structDef.getName() + ": not a struct type");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, structDef.getName(), TypeCategory.STRUCT.name());
         }
 
         AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.STRUCT);
 
         if (vertex == null) {
-            throw new AtlasBaseException("no structDef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         AtlasStructDefStoreV1.updateVertexPreUpdate(structDef, (AtlasStructType)type, vertex, typeDefStore);
@@ -263,7 +264,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT);
 
         if (ret == null) {
-            throw new AtlasBaseException("no structDef exists with name " + name);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
         }
 
         typeDefStore.deleteTypeVertexOutEdges(ret);
@@ -305,7 +306,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
         AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.STRUCT);
 
         if (ret == null) {
-            throw new AtlasBaseException("no structDef exists with guid " + guid);
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
         }
 
         typeDefStore.deleteTypeVertexOutEdges(ret);
@@ -477,7 +478,7 @@ public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements At
                 AtlasVertex referencedTypeVertex = typeDefStore.findTypeVertexByName(referencedTypeName);
 
                 if (referencedTypeVertex == null) {
-                    throw new AtlasBaseException(referencedTypeName + ": unknown datatype");
+                    throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_TYPE, referencedTypeName, typeName, attributeDef.getName());
                 }
 
                 String label = AtlasGraphUtilsV1.getEdgeLabel(typeName, attributeDef.getName());

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
index 5131906..80feaf6 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
@@ -20,6 +20,8 @@ package org.apache.atlas.repository.store.graph.v1;
 import com.google.common.base.Preconditions;
 
 import com.google.inject.Inject;
+import org.apache.atlas.AtlasConstants;
+import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
 import org.apache.atlas.model.typedef.AtlasClassificationDef;
@@ -232,7 +234,7 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
         Iterator<AtlasEdge> inEdges = vertex.getEdges(AtlasEdgeDirection.IN).iterator();
 
         if (inEdges.hasNext()) {
-            throw new AtlasBaseException("has references");
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES);
         }
 
         Iterable<AtlasEdge> edges = vertex.getEdges(AtlasEdgeDirection.OUT);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java b/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java
new file mode 100644
index 0000000..9042e88
--- /dev/null
+++ b/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License 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 org.apache.atlas.web.errors;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+import javax.inject.Singleton;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+/**
+ * Exception mapper for Jersey.
+ * @param <E>
+ */
+@Provider
+@Singleton
+public class AllExceptionMapper implements ExceptionMapper<Exception> {
+    private static final Logger LOGGER = LoggerFactory.getLogger(AllExceptionMapper.class);
+
+    @Override
+    public Response toResponse(Exception exception) {
+        final long id = ThreadLocalRandom.current().nextLong();
+
+        // Log the response and use the error codes from the Exception
+        ExceptionMapperUtil.logException(id, exception);
+        return Response
+                .serverError()
+                .entity(ExceptionMapperUtil.formatErrorMessage(id, exception))
+                .build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java b/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java
new file mode 100755
index 0000000..70b2482
--- /dev/null
+++ b/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License 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 org.apache.atlas.web.errors;
+
+import org.apache.atlas.AtlasErrorCode;
+import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.type.AtlasType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.ThreadLocalRandom;
+
+import javax.inject.Singleton;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+/**
+ * Exception mapper for Jersey.
+ * @param <E>
+ */
+@Provider
+@Singleton
+public class AtlasBaseExceptionMapper implements ExceptionMapper<AtlasBaseException> {
+    private static final Logger LOGGER = LoggerFactory.getLogger(AtlasBaseExceptionMapper.class);
+
+    @Override
+    public Response toResponse(AtlasBaseException exception) {
+        final long id = ThreadLocalRandom.current().nextLong();
+
+        // Log the response and use the error codes from the Exception
+        logException(id, exception);
+        return buildAtlasBaseExceptionResponse((AtlasBaseException) exception);
+    }
+
+    protected Response buildAtlasBaseExceptionResponse(AtlasBaseException baseException) {
+        Map<String, String> errorJsonMap = new LinkedHashMap<>();
+        AtlasErrorCode errorCode = baseException.getAtlasErrorCode();
+        errorJsonMap.put("errorCode", errorCode.getErrorCode());
+        errorJsonMap.put("errorMessage", baseException.getMessage());
+        Response.ResponseBuilder responseBuilder = Response.status(errorCode.getHttpCode());
+
+        // No body for 204 (and maybe 304)
+        if (Response.Status.NO_CONTENT != errorCode.getHttpCode()) {
+            responseBuilder.entity(AtlasType.toJson(errorJsonMap));
+        }
+        return responseBuilder.build();
+    }
+
+    @SuppressWarnings("UnusedParameters")
+    protected String formatErrorMessage(long id, AtlasBaseException exception) {
+        return String.format("There was an error processing your request. It has been logged (ID %016x).", id);
+    }
+
+    protected void logException(long id, AtlasBaseException exception) {
+        LOGGER.error(formatLogMessage(id, exception), exception);
+    }
+
+    @SuppressWarnings("UnusedParameters")
+    protected String formatLogMessage(long id, Throwable exception) {
+        return String.format("Error handling a request: %016x", id);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/webapp/src/main/java/org/apache/atlas/web/errors/ExceptionMapperUtil.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/errors/ExceptionMapperUtil.java b/webapp/src/main/java/org/apache/atlas/web/errors/ExceptionMapperUtil.java
new file mode 100644
index 0000000..a14f939
--- /dev/null
+++ b/webapp/src/main/java/org/apache/atlas/web/errors/ExceptionMapperUtil.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License 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 org.apache.atlas.web.errors;
+
+import org.apache.atlas.exception.AtlasBaseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ExceptionMapperUtil {
+    protected static final Logger LOGGER = LoggerFactory.getLogger(ExceptionMapperUtil.class);
+
+    @SuppressWarnings("UnusedParameters")
+    protected static String formatErrorMessage(long id, Exception exception) {
+        return String.format("There was an error processing your request. It has been logged (ID %016x).", id);
+    }
+
+    protected static void logException(long id, Exception exception) {
+        LOGGER.error(formatLogMessage(id, exception), exception);
+    }
+
+    @SuppressWarnings("UnusedParameters")
+    protected static String formatLogMessage(long id, Throwable exception) {
+        return String.format("Error handling a request: %016x", id);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/webapp/src/main/java/org/apache/atlas/web/errors/LoggingExceptionMapper.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/errors/LoggingExceptionMapper.java b/webapp/src/main/java/org/apache/atlas/web/errors/LoggingExceptionMapper.java
deleted file mode 100755
index 9830269..0000000
--- a/webapp/src/main/java/org/apache/atlas/web/errors/LoggingExceptionMapper.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License 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 org.apache.atlas.web.errors;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ExceptionMapper;
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * Exception mapper for Jersey.
- * @param <E>
- */
-public class LoggingExceptionMapper<E extends Throwable> implements ExceptionMapper<E> {
-    private static final Logger LOGGER = LoggerFactory.getLogger(LoggingExceptionMapper.class);
-
-    @Override
-    public Response toResponse(E exception) {
-        if (exception instanceof WebApplicationException) {
-            return ((WebApplicationException) exception).getResponse();
-        }
-
-        final long id = ThreadLocalRandom.current().nextLong();
-        logException(id, exception);
-        return Response.serverError().entity(formatErrorMessage(id, exception)).build();
-    }
-
-    @SuppressWarnings("UnusedParameters")
-    protected String formatErrorMessage(long id, E exception) {
-        return String.format("There was an error processing your request. It has been logged (ID %016x).", id);
-    }
-
-    protected void logException(long id, E exception) {
-        LOGGER.error(formatLogMessage(id, exception), exception);
-    }
-
-    @SuppressWarnings("UnusedParameters")
-    protected String formatLogMessage(long id, Throwable exception) {
-        return String.format("Error handling a request: %016x", id);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
index a39dfb0..a2cfc62 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
@@ -66,7 +66,6 @@ public class TypesREST {
 
     @Inject
     public TypesREST(AtlasTypeDefStore typeDefStore) {
-        LOG.info("new TypesREST");
         this.typeDefStore = typeDefStore;
     }
 
@@ -76,24 +75,17 @@ public class TypesREST {
     @Path("/enumdef")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasEnumDef createEnumDef(AtlasEnumDef enumDef) throws Exception {
-        AtlasEnumDef ret = null;
+    public AtlasEnumDef createEnumDef(AtlasEnumDef enumDef) throws AtlasBaseException {
+        AtlasEnumDef ret = typeDefStore.createEnumDef(enumDef);
 
-        try {
-            ret = typeDefStore.createEnumDef(enumDef);
-            return ret;
-        } catch (AtlasBaseException ex) {
-            throw new WebApplicationException(Servlets.getErrorResponse(ex, Response.Status.BAD_REQUEST));
-        }
+        return ret;
     }
 
     @GET
     @Path("/enumdef/name/{name}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasEnumDef getEnumDefByName(@PathParam("name") String name) throws Exception {
-        AtlasEnumDef ret = null;
-
-        ret = typeDefStore.getEnumDefByName(name);
+    public AtlasEnumDef getEnumDefByName(@PathParam("name") String name) throws AtlasBaseException {
+        AtlasEnumDef ret = typeDefStore.getEnumDefByName(name);
 
         return ret;
     }
@@ -101,10 +93,8 @@ public class TypesREST {
     @GET
     @Path("/enumdef/guid/{guid}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasEnumDef getEnumDefByGuid(@PathParam("guid") String guid) throws Exception {
-        AtlasEnumDef ret = null;
-
-        ret = typeDefStore.getEnumDefByGuid(guid);
+    public AtlasEnumDef getEnumDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
+        AtlasEnumDef ret = typeDefStore.getEnumDefByGuid(guid);
 
         return ret;
     }
@@ -113,10 +103,8 @@ public class TypesREST {
     @Path("/enumdef/name/{name}")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasEnumDef updateEnumDefByName(@PathParam("name") String name, AtlasEnumDef enumDef) throws Exception {
-        AtlasEnumDef ret = null;
-
-        ret = typeDefStore.updateEnumDefByName(name, enumDef);
+    public AtlasEnumDef updateEnumDefByName(@PathParam("name") String name, AtlasEnumDef enumDef) throws AtlasBaseException {
+        AtlasEnumDef ret = typeDefStore.updateEnumDefByName(name, enumDef);
 
         return ret;
     }
@@ -125,10 +113,8 @@ public class TypesREST {
     @Path("/enumdef/guid/{guid}")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasEnumDef updateEnumDefByGuid(@PathParam("guid") String guid, AtlasEnumDef enumDef) throws Exception {
-        AtlasEnumDef ret = null;
-
-        ret = typeDefStore.updateEnumDefByGuid(guid, enumDef);
+    public AtlasEnumDef updateEnumDefByGuid(@PathParam("guid") String guid, AtlasEnumDef enumDef) throws AtlasBaseException {
+        AtlasEnumDef ret = typeDefStore.updateEnumDefByGuid(guid, enumDef);
 
         return ret;
     }
@@ -136,21 +122,21 @@ public class TypesREST {
     @DELETE
     @Path("/enumdef/name/{name}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public void deleteEnumDefByName(@PathParam("name") String name) throws Exception {
+    public void deleteEnumDefByName(@PathParam("name") String name) throws AtlasBaseException {
         typeDefStore.deleteEnumDefByName(name);
     }
 
     @DELETE
     @Path("/enumdef/guid/{guid}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public void deleteEnumDefByGuid(@PathParam("guid") String guid) throws Exception {
+    public void deleteEnumDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
         typeDefStore.deleteEnumDefByGuid(guid);
     }
 
     @GET
     @Path("/enumdef")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasEnumDefs searchEnumDefs() throws Exception {
+    public AtlasEnumDefs searchEnumDefs() throws AtlasBaseException {
         AtlasEnumDefs ret = null;
 
         SearchFilter filter = getSearchFilter();
@@ -167,25 +153,17 @@ public class TypesREST {
     @Path("/structdef")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasStructDef createStructDef(AtlasStructDef structDef) throws Exception {
-        AtlasStructDef ret = null;
-
-        try {
-            ret = typeDefStore.createStructDef(structDef);
-            return ret;
-        } catch (AtlasBaseException ex) {
-            throw new WebApplicationException(Servlets.getErrorResponse(ex, Response.Status.BAD_REQUEST));
-        }
+    public AtlasStructDef createStructDef(AtlasStructDef structDef) throws AtlasBaseException {
+        AtlasStructDef ret = typeDefStore.createStructDef(structDef);
 
+        return ret;
     }
 
     @GET
     @Path("/structdef/name/{name}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasStructDef getStructDefByName(@PathParam("name") String name) throws Exception {
-        AtlasStructDef ret = null;
-
-        ret = typeDefStore.getStructDefByName(name);
+    public AtlasStructDef getStructDefByName(@PathParam("name") String name) throws AtlasBaseException {
+        AtlasStructDef ret = typeDefStore.getStructDefByName(name);
 
         return ret;
     }
@@ -193,10 +171,8 @@ public class TypesREST {
     @GET
     @Path("/structdef/guid/{guid}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasStructDef getStructDefByGuid(@PathParam("guid") String guid) throws Exception {
-        AtlasStructDef ret = null;
-
-        ret = typeDefStore.getStructDefByGuid(guid);
+    public AtlasStructDef getStructDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
+        AtlasStructDef ret = typeDefStore.getStructDefByGuid(guid);
 
         return ret;
     }
@@ -205,10 +181,8 @@ public class TypesREST {
     @Path("/structdef/name/{name}")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasStructDef updateStructDefByName(@PathParam("name") String name, AtlasStructDef structDef) throws Exception {
-        AtlasStructDef ret = null;
-
-        ret = typeDefStore.updateStructDefByName(name, structDef);
+    public AtlasStructDef updateStructDefByName(@PathParam("name") String name, AtlasStructDef structDef) throws AtlasBaseException {
+        AtlasStructDef ret = typeDefStore.updateStructDefByName(name, structDef);
 
         return ret;
     }
@@ -217,10 +191,8 @@ public class TypesREST {
     @Path("/structdef/guid/{guid}")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasStructDef updateStructDefByGuid(@PathParam("guid") String guid, AtlasStructDef structDef) throws Exception {
-        AtlasStructDef ret = null;
-
-        ret = typeDefStore.updateStructDefByGuid(guid, structDef);
+    public AtlasStructDef updateStructDefByGuid(@PathParam("guid") String guid, AtlasStructDef structDef) throws AtlasBaseException {
+        AtlasStructDef ret = typeDefStore.updateStructDefByGuid(guid, structDef);
 
         return ret;
     }
@@ -228,25 +200,23 @@ public class TypesREST {
     @DELETE
     @Path("/structdef/name/{name}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public void deleteStructDefByName(@PathParam("name") String name) throws Exception {
+    public void deleteStructDefByName(@PathParam("name") String name) throws AtlasBaseException {
         typeDefStore.deleteStructDefByName(name);
     }
 
     @DELETE
     @Path("/structdef/guid/{guid}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public void deleteStructDefByGuid(@PathParam("guid") String guid) throws Exception {
+    public void deleteStructDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
         typeDefStore.deleteStructDefByGuid(guid);
     }
 
     @GET
     @Path("/structdef")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasStructDefs searchStructDefs() throws Exception {
-        AtlasStructDefs ret = null;
-
+    public AtlasStructDefs searchStructDefs() throws AtlasBaseException {
         SearchFilter filter = getSearchFilter();
-        ret = typeDefStore.searchStructDefs(filter);
+        AtlasStructDefs ret = typeDefStore.searchStructDefs(filter);
 
         return ret;
     }
@@ -257,24 +227,17 @@ public class TypesREST {
     @Path("/classificationdef")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasClassificationDef createClassificationDef(AtlasClassificationDef classificationDef) throws Exception {
-        AtlasClassificationDef ret = null;
+    public AtlasClassificationDef createClassificationDef(AtlasClassificationDef classificationDef) throws AtlasBaseException {
+        AtlasClassificationDef ret = typeDefStore.createClassificationDef(classificationDef);
 
-        try {
-            ret = typeDefStore.createClassificationDef(classificationDef);
-            return ret;
-        } catch (AtlasBaseException ex) {
-            throw new WebApplicationException(Servlets.getErrorResponse(ex, Response.Status.BAD_REQUEST));
-        }
+        return ret;
     }
 
     @GET
     @Path("/classificationdef/name/{name}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasClassificationDef getClassificationDefByName(@PathParam("name") String name) throws Exception {
-        AtlasClassificationDef ret = null;
-
-        ret = typeDefStore.getClassificationDefByName(name);
+    public AtlasClassificationDef getClassificationDefByName(@PathParam("name") String name) throws AtlasBaseException {
+        AtlasClassificationDef ret = typeDefStore.getClassificationDefByName(name);
 
         return ret;
     }
@@ -282,10 +245,8 @@ public class TypesREST {
     @GET
     @Path("/classificationdef/guid/{guid}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasClassificationDef getClassificationDefByGuid(@PathParam("guid") String guid) throws Exception {
-        AtlasClassificationDef ret = null;
-
-        ret = typeDefStore.getClassificationDefByGuid(guid);
+    public AtlasClassificationDef getClassificationDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
+        AtlasClassificationDef ret = typeDefStore.getClassificationDefByGuid(guid);
 
         return ret;
     }
@@ -294,10 +255,8 @@ public class TypesREST {
     @Path("/classificationdef/name/{name}")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasClassificationDef updateClassificationDefByName(@PathParam("name") String name, AtlasClassificationDef classificationDef) throws Exception {
-        AtlasClassificationDef ret = null;
-
-        ret = typeDefStore.updateClassificationDefByName(name, classificationDef);
+    public AtlasClassificationDef updateClassificationDefByName(@PathParam("name") String name, AtlasClassificationDef classificationDef) throws AtlasBaseException {
+        AtlasClassificationDef ret = typeDefStore.updateClassificationDefByName(name, classificationDef);
 
         return ret;
     }
@@ -306,10 +265,8 @@ public class TypesREST {
     @Path("/classificationdef/guid/{guid}")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasClassificationDef updateClassificationDefByGuid(@PathParam("guid") String guid, AtlasClassificationDef classificationDef) throws Exception {
-        AtlasClassificationDef ret = null;
-
-        ret = typeDefStore.updateClassificationDefByGuid(guid, classificationDef);
+    public AtlasClassificationDef updateClassificationDefByGuid(@PathParam("guid") String guid, AtlasClassificationDef classificationDef) throws AtlasBaseException {
+        AtlasClassificationDef ret = typeDefStore.updateClassificationDefByGuid(guid, classificationDef);
 
         return ret;
     }
@@ -317,14 +274,14 @@ public class TypesREST {
     @DELETE
     @Path("/classificationdef/name/{name}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public void deleteClassificationDefByName(@PathParam("name") String name) throws Exception {
+    public void deleteClassificationDefByName(@PathParam("name") String name) throws AtlasBaseException {
         typeDefStore.deleteClassificationDefByName(name);
     }
 
     @DELETE
     @Path("/classificationdef/guid/{guid}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public void deleteClassificationDefByGuid(@PathParam("guid") String guid) throws Exception {
+    public void deleteClassificationDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
         typeDefStore.deleteClassificationDefByGuid(guid);
     }
 
@@ -332,11 +289,10 @@ public class TypesREST {
     @Path("/classificationdef")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasClassificationDefs searchClassificationDefs() throws Exception {
-        AtlasClassificationDefs ret = null;
-
+    public AtlasClassificationDefs searchClassificationDefs() throws AtlasBaseException {
         SearchFilter filter = getSearchFilter();
-        ret = typeDefStore.searchClassificationDefs(filter);
+
+        AtlasClassificationDefs ret = typeDefStore.searchClassificationDefs(filter);
 
         return ret;
     }
@@ -347,8 +303,8 @@ public class TypesREST {
     @Path("/entitydef")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasEntityDef createEntityDef(AtlasEntityDef entityDef) throws Exception {
-        AtlasEntityDef ret = null;
+    public AtlasEntityDef createEntityDef(AtlasEntityDef entityDef) throws AtlasBaseException {
+        AtlasEntityDef ret = typeDefStore.createEntityDef(entityDef);
 
         try {
             ret = typeDefStore.createEntityDef(entityDef);
@@ -361,10 +317,8 @@ public class TypesREST {
     @GET
     @Path("/entitydef/name/{name}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasEntityDef getEntityDefByName(@PathParam("name") String name) throws Exception {
-        AtlasEntityDef ret = null;
-
-        ret = typeDefStore.getEntityDefByName(name);
+    public AtlasEntityDef getEntityDefByName(@PathParam("name") String name) throws AtlasBaseException {
+        AtlasEntityDef ret = typeDefStore.getEntityDefByName(name);
 
         return ret;
     }
@@ -372,10 +326,8 @@ public class TypesREST {
     @GET
     @Path("/entitydef/guid/{guid}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasEntityDef getEntityDefByGuid(@PathParam("guid") String guid) throws Exception {
-        AtlasEntityDef ret = null;
-
-        ret = typeDefStore.getEntityDefByGuid(guid);
+    public AtlasEntityDef getEntityDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
+        AtlasEntityDef ret = typeDefStore.getEntityDefByGuid(guid);
 
         return ret;
     }
@@ -425,11 +377,9 @@ public class TypesREST {
     @GET
     @Path("/entitydef")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasEntityDefs searchEntityDefs() throws Exception {
-        AtlasEntityDefs ret = null;
-
+    public AtlasEntityDefs searchEntityDefs() throws AtlasBaseException {
         SearchFilter filter = getSearchFilter();
-        ret = typeDefStore.searchEntityDefs(filter);
+        AtlasEntityDefs ret = typeDefStore.searchEntityDefs(filter);
 
         return ret;
     }
@@ -447,16 +397,10 @@ public class TypesREST {
     @GET
     @Path("/typedefs")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasTypesDef getAllTypeDefs() throws Exception {
+    public AtlasTypesDef getAllTypeDefs() throws AtlasBaseException {
         SearchFilter searchFilter = getSearchFilter();
 
-        AtlasTypesDef typesDef = null;
-
-        try {
-            typesDef = typeDefStore.searchTypesDef(searchFilter);
-        } catch (AtlasBaseException ex) {
-            throw new WebApplicationException(Servlets.getErrorResponse(ex, Response.Status.NOT_FOUND));
-        }
+        AtlasTypesDef typesDef = typeDefStore.searchTypesDef(searchFilter);
 
         return typesDef;
     }
@@ -473,13 +417,9 @@ public class TypesREST {
     @Path("/typedefs")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public AtlasTypesDef createAtlasTypeDefs(final AtlasTypesDef typesDef) throws Exception {
-        AtlasTypesDef ret = null;
-        try {
-            ret = typeDefStore.createTypesDef(typesDef);
-        } catch (AtlasBaseException ex) {
-            throw new WebApplicationException(Servlets.getErrorResponse(ex, Response.Status.BAD_REQUEST));
-        }
+    public AtlasTypesDef createAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasBaseException {
+        AtlasTypesDef ret = typeDefStore.createTypesDef(typesDef);
+
         return ret;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fdf97ae4/webapp/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/webapp/src/main/webapp/WEB-INF/web.xml b/webapp/src/main/webapp/WEB-INF/web.xml
index c551814..7c6bc6d 100755
--- a/webapp/src/main/webapp/WEB-INF/web.xml
+++ b/webapp/src/main/webapp/WEB-INF/web.xml
@@ -27,7 +27,7 @@
     <context-param>
         <param-name>guice.packages</param-name>
         <param-value>
-            org.apache.atlas.web.resources,org.apache.atlas.web.params,org.apache.atlas.web.rest
+            org.apache.atlas.web.resources,org.apache.atlas.web.params,org.apache.atlas.web.rest,org.apache.atlas.web.errors
         </param-value>
     </context-param>
   


Mime
View raw message