falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajayyad...@apache.org
Subject falcon git commit: FALCON-1705 Standardization of error handling in falcon Server. Contributed by Praveen Adlakha.
Date Wed, 06 Jan 2016 14:07:49 GMT
Repository: falcon
Updated Branches:
  refs/heads/0.9 d856c0780 -> 2cbf5030c


FALCON-1705  Standardization of error handling in falcon Server. Contributed by Praveen Adlakha.


Project: http://git-wip-us.apache.org/repos/asf/falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/2cbf5030
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/2cbf5030
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/2cbf5030

Branch: refs/heads/0.9
Commit: 2cbf5030c5ebbad1ce524c9bb048c0e886be7ed4
Parents: d856c07
Author: Ajay Yadava <ajaynsit@gmail.com>
Authored: Wed Jan 6 18:25:22 2016 +0530
Committer: Ajay Yadava <ajaynsit@gmail.com>
Committed: Wed Jan 6 19:18:46 2016 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +
 .../org/apache/falcon/FalconWebException.java   | 89 +++++---------------
 .../falcon/resource/AbstractEntityManager.java  | 54 ++++++------
 .../resource/AbstractInstanceManager.java       | 85 +++++++++----------
 .../AbstractSchedulableEntityManager.java       | 50 +++++------
 .../falcon/resource/channel/HTTPChannel.java    |  4 +-
 .../metadata/LineageMetadataResource.java       | 20 ++---
 .../metadata/MetadataDiscoveryResource.java     |  4 +-
 .../falcon/resource/proxy/BufferedRequest.java  |  2 +-
 .../resource/proxy/InstanceManagerProxy.java    | 39 ++++-----
 .../proxy/SchedulableEntityManagerProxy.java    | 54 ++++++------
 .../resource/SchedulableEntityManager.java      | 13 ++-
 12 files changed, 180 insertions(+), 236 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5677175..fbb5dc9 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -43,6 +43,8 @@ Proposed Release Version: 0.9
     FALCON-1213 Base framework of the native scheduler(Pallavi Rao)
 
   IMPROVEMENTS
+    FALCON-1705 Standardization of error handling in falcon Server(Praveen Adlakha via Ajay Yadava)
+
     FALCON-1640 Cascading Delete for instances in Native Scheduler(Pavan Kumar Kolamuri via Ajay Yadava)
 
     FALCON-1683 Inconsistent behavior when user tries to switch schedulers(Pallavi Rao via Ajay Yadava)

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/prism/src/main/java/org/apache/falcon/FalconWebException.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/FalconWebException.java b/prism/src/main/java/org/apache/falcon/FalconWebException.java
index 0b6c38e..663420a 100644
--- a/prism/src/main/java/org/apache/falcon/FalconWebException.java
+++ b/prism/src/main/java/org/apache/falcon/FalconWebException.java
@@ -18,19 +18,15 @@
 
 package org.apache.falcon;
 
-import org.apache.falcon.resource.APIResult;
-import org.apache.falcon.resource.InstanceDependencyResult;
-import org.apache.falcon.resource.InstancesResult;
-import org.apache.falcon.resource.InstancesSummaryResult;
-import org.apache.falcon.resource.TriageResult;
-import org.apache.hadoop.security.authorize.AuthorizationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
+import org.apache.falcon.resource.APIResult;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Exception for REST APIs.
  */
@@ -38,81 +34,38 @@ public class FalconWebException extends WebApplicationException {
 
     private static final Logger LOG = LoggerFactory.getLogger(FalconWebException.class);
 
-    public static FalconWebException newException(Throwable e,
-                                                  Response.Status status) {
-        if (e instanceof AuthorizationException) {
-            status = Response.Status.FORBIDDEN;
-        }
-
-        return newException(getMessage(e), status);
-    }
-
-    public static FalconWebException newTriageResultException(Throwable e, Response.Status status) {
-        String message = getMessage(e);
-        LOG.error("Triage failed: {}\nError: {}", status, message);
-        APIResult result = new TriageResult(APIResult.Status.FAILED, message);
-        return new FalconWebException(e, Response.status(status).entity(result).type(MediaType.TEXT_XML_TYPE).build());
-    }
-
-    public static FalconWebException newInstanceSummaryException(Throwable e, Response.Status status) {
-        String message = getMessage(e);
-        LOG.error("Action failed: {}\nError: {}", status, message);
-        APIResult result = new InstancesSummaryResult(APIResult.Status.FAILED, message);
-        return new FalconWebException(e, Response.status(status).entity(result).type(MediaType.TEXT_XML_TYPE).build());
-    }
-
-    public static FalconWebException newInstanceDependencyResult(Throwable e, Response.Status status) {
-        return newInstanceDependencyResult(getMessage(e), status);
-    }
-
-    public static FalconWebException newInstanceDependencyResult(String message, Response.Status status) {
+    public static FalconWebException newMetadataResourceException(String message, Response.Status status) {
         LOG.error("Action failed: {}\nError: {}", status, message);
-        APIResult result = new InstanceDependencyResult(APIResult.Status.FAILED, message);
+        // Using MediaType.TEXT_PLAIN for newMetadataResourceException to ensure backward compatibility.
         return new FalconWebException(new Exception(message),
-                Response.status(status).entity(result).type(MediaType.TEXT_XML_TYPE).build());
-    }
-
-    public static FalconWebException newException(String message, Response.Status status) {
-        APIResult result = new APIResult(APIResult.Status.FAILED, message);
-        return newException(result, status);
+                Response.status(status).entity(message).type(MediaType.TEXT_PLAIN).build());
     }
 
-    public static FalconWebException newException(APIResult result, Response.Status status) {
-        LOG.error("Action failed: {}\nError: {}", status, result.getMessage());
-        return new FalconWebException(new FalconException(result.getMessage()),
-                Response.status(status).entity(result).type(MediaType.TEXT_XML_TYPE).build());
+    public static FalconWebException newAPIException(Throwable throwable) {
+        return newAPIException(throwable, Response.Status.BAD_REQUEST);
     }
 
-    public static FalconWebException newInstanceException(String message, Response.Status status) {
-        return newInstanceException(new FalconException(message), status);
+    public static FalconWebException newAPIException(Throwable throwable, Response.Status status) {
+        String message = getMessage(throwable);
+        return newAPIException(message, status);
     }
 
-    public static FalconWebException newInstanceException(Throwable e, Response.Status status) {
-        LOG.error("Action failed: {}\nError: {}", status, e.getMessage());
-        APIResult result = new InstancesResult(APIResult.Status.FAILED, e.getMessage());
-        return new FalconWebException(e, Response.status(status).entity(result).type(MediaType.TEXT_XML_TYPE).build());
+    public static FalconWebException newAPIException(String message) {
+        return newAPIException(message, Response.Status.BAD_REQUEST);
     }
 
-    public static FalconWebException newMetadataResourceException(String message, Response.Status status) {
-        LOG.error("Action failed: {}\nError: {}", status, message);
-        // Using MediaType.TEXT_PLAIN for newMetadataResourceException to ensure backward compatibility.
-        return new FalconWebException(new Exception(message),
-                Response.status(status).entity(message).type(MediaType.TEXT_PLAIN).build());
+    public static FalconWebException newAPIException(String message, Response.Status status) {
+        Response response = Response.status(status)
+                .entity(new APIResult(APIResult.Status.FAILED, message))
+                .type(MediaType.TEXT_XML_TYPE)
+                .build();
+        return new FalconWebException(response);
     }
 
     private static String getMessage(Throwable e) {
         return e.getCause()==null? e.getMessage():e.getMessage() + "\nCausedBy: " + e.getCause().getMessage();
     }
 
-
-    public static FalconWebException newAPIException(String message) {
-        Response response = Response.status(Response.Status.BAD_REQUEST)
-                            .entity(new APIResult(APIResult.Status.FAILED, message))
-                            .type(MediaType.TEXT_XML_TYPE)
-                            .build();
-        return new FalconWebException(response);
-    }
-
     public FalconWebException(Response response) {
         super(response);
     }

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java b/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
index 0ea2e4e..c32123d 100644
--- a/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
+++ b/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
@@ -101,9 +101,8 @@ public abstract class AbstractEntityManager {
         }
         if (StringUtils.isNotEmpty(colo) && !colo.equals("*")) {
             if (!DeploymentUtil.getCurrentColo().equals(colo)) {
-                throw FalconWebException.newException(
-                        "Current colo (" + DeploymentUtil.getCurrentColo() + ") is not " + colo,
-                        Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException("Current colo (" + DeploymentUtil.getCurrentColo()
+                        + ") is not " + colo);
             }
         }
     }
@@ -127,8 +126,7 @@ public abstract class AbstractEntityManager {
         } else {
             colos = new HashSet<String>(Arrays.asList(coloExpr.split(",")));
             if (!applicableColos.containsAll(colos)) {
-                throw FalconWebException.newException("Given colos not applicable for entity operation",
-                        Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException("Given colos not applicable for entity operation");
             }
         }
         return colos;
@@ -146,7 +144,7 @@ public abstract class AbstractEntityManager {
 
             return getApplicableColos(type, EntityUtil.getEntity(type, name));
         } catch (FalconException e) {
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -168,7 +166,7 @@ public abstract class AbstractEntityManager {
             }
             return colos;
         } catch (FalconException e) {
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -194,7 +192,7 @@ public abstract class AbstractEntityManager {
             return new APIResult(APIResult.Status.SUCCEEDED, "Submit successful (" + type + ") " + entity.getName());
         } catch (Throwable e) {
             LOG.error("Unable to persist entity object", e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -210,7 +208,7 @@ public abstract class AbstractEntityManager {
             return validate(request.getInputStream(), type, skipDryRun);
         } catch (IOException e) {
             LOG.error("Unable to get InputStream from Request", request, e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -235,7 +233,7 @@ public abstract class AbstractEntityManager {
                     "Validated successfully (" + entityType + ") " + entity.getName());
         } catch (Throwable e) {
             LOG.error("Validation failed for entity ({})", type, e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -278,7 +276,7 @@ public abstract class AbstractEntityManager {
                     entity + "(" + type + ") removed successfully " + removedFromEngine);
         } catch (Throwable e) {
             LOG.error("Unable to reach workflow engine for deletion or deletion failed", e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         } finally {
             releaseEntityLocks(entity, tokenList);
         }
@@ -290,13 +288,13 @@ public abstract class AbstractEntityManager {
             return update(request.getInputStream(), type, entityName, colo, skipDryRun);
         } catch (IOException e) {
             LOG.error("Unable to get InputStream from Request", request, e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
 
     }
 
     protected APIResult update(InputStream inputStream, String type, String entityName,
-                            String colo, Boolean skipDryRun) {
+                               String colo, Boolean skipDryRun) {
         checkColo(colo);
         List<Entity> tokenList = new ArrayList<>();
         try {
@@ -332,7 +330,7 @@ public abstract class AbstractEntityManager {
             return new APIResult(APIResult.Status.SUCCEEDED, result.toString());
         } catch (Throwable e) {
             LOG.error("Update failed", e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         } finally {
             ConfigurationStore.get().cleanupUpdateInit();
             releaseEntityLocks(entityName, tokenList);
@@ -561,7 +559,7 @@ public abstract class AbstractEntityManager {
             throw e;
         } catch (Exception e) {
             LOG.error("Unable to get status for entity {} ({})", entity, type, e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -596,7 +594,7 @@ public abstract class AbstractEntityManager {
             return EntityUtil.getEntityDependencies(entityObj);
         } catch (Exception e) {
             LOG.error("Unable to get dependencies for entityName {} ({})", entityName, type, e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -652,7 +650,7 @@ public abstract class AbstractEntityManager {
             }
         } catch (Exception e) {
             LOG.error("Failed to get entity list", e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
 
         // sort entities and pagination
@@ -685,8 +683,7 @@ public abstract class AbstractEntityManager {
             try {
                 EntityList.EntityFilterByFields.valueOf(entry.getKey().toUpperCase());
             } catch (IllegalArgumentException e) {
-                throw FalconWebException.newInstanceException(
-                        "Invalid filter key: " + entry.getKey(), Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException("Invalid filter key: " + entry.getKey());
             }
         }
         return filterByFieldsValues;
@@ -724,7 +721,7 @@ public abstract class AbstractEntityManager {
                 }
             } catch (FalconException e1) {
                 LOG.error("Unable to get list for entities for ({})", entityType.getEntityClass().getSimpleName(), e1);
-                throw FalconWebException.newException(e1, Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException(e1);
             }
 
             if (SecurityUtil.isAuthorizationEnabled() && !isEntityAuthorized(entity)) {
@@ -955,9 +952,9 @@ public abstract class AbstractEntityManager {
 
         case PIPELINES:
             if (!entity.getEntityType().equals(EntityType.PROCESS)) {
-                throw FalconWebException.newException(
-                        "Invalid filterBy key for non process entities " + pair.getKey(),
-                        Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException("Invalid filterBy key for non"
+                    + " process entities " + pair.getKey());
+
             }
             return isFilteredByPipelines(pair.getValue(), EntityUtil.getPipelines(entity));
 
@@ -1009,7 +1006,7 @@ public abstract class AbstractEntityManager {
 
         String err = "Value for param sortOrder should be \"asc\" or \"desc\". It is  : " + sortOrder;
         LOG.error(err);
-        throw FalconWebException.newException(err, Response.Status.BAD_REQUEST);
+        throw FalconWebException.newAPIException(err);
     }
 
     protected int getRequiredNumberOfResults(int arraySize, int offset, int numresults) {
@@ -1021,8 +1018,7 @@ public abstract class AbstractEntityManager {
 
         if (numresults < 1) {
             LOG.error("Value for param numResults should be > than 0  : {}", numresults);
-            throw FalconWebException.newException("Value for param numResults should be > than 0  : " + numresults,
-                    Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException("Value for param numResults should be > than 0  : " + numresults);
         }
 
         if (offset < 0) { offset = 0; }
@@ -1084,7 +1080,7 @@ public abstract class AbstractEntityManager {
             return entity.toString();
         } catch (Throwable e) {
             LOG.error("Unable to get entity definition from config store for ({}): {}", type, entityName, e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
 
         }
     }
@@ -1126,10 +1122,10 @@ public abstract class AbstractEntityManager {
             return result;
 
         } catch (IllegalArgumentException e) {
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         } catch (Throwable throwable) {
             LOG.error("reverse look up failed", throwable);
-            throw FalconWebException.newException(throwable, Response.Status.INTERNAL_SERVER_ERROR);
+            throw FalconWebException.newAPIException(throwable, Response.Status.INTERNAL_SERVER_ERROR);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java b/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java
index d50d111..9e81209 100644
--- a/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java
+++ b/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java
@@ -18,6 +18,25 @@
 
 package org.apache.falcon.resource;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Queue;
+import java.util.Set;
+
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.falcon.FalconException;
 import org.apache.falcon.FalconWebException;
@@ -44,28 +63,10 @@ import org.apache.falcon.resource.InstancesResult.Instance;
 import org.apache.falcon.resource.InstancesSummaryResult.InstanceSummary;
 import org.apache.falcon.util.DeploymentUtil;
 import org.apache.falcon.workflow.engine.AbstractWorkflowEngine;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Properties;
-import java.util.Queue;
-import java.util.Set;
-
 /**
  * A base class for managing Entity's Instance operations.
  */
@@ -79,14 +80,12 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
 
     protected EntityType checkType(String type) {
         if (StringUtils.isEmpty(type)) {
-            throw FalconWebException.newInstanceException("entity type is empty",
-                    Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException("entity type is empty");
         } else {
             EntityType entityType = EntityType.getEnum(type);
             if (entityType == EntityType.CLUSTER) {
-                throw FalconWebException.newInstanceException(
-                        "Instance management functions don't apply to Cluster entities",
-                        Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException(
+                        "Instance management functions don't apply to Cluster entities");
             }
             return entityType;
         }
@@ -129,7 +128,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                     filterBy, orderBy, sortOrder, offset, numResults);
         } catch (Throwable e) {
             LOG.error("Failed to get running instances", e);
-            throw FalconWebException.newInstanceException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -143,11 +142,9 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                     getEarliestDate(entry.getValue());
                 }
             } catch (IllegalArgumentException e) {
-                throw FalconWebException.newInstanceException(
-                        "Invalid filter key: " + entry.getKey(), Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException("Invalid filter key: " + entry.getKey());
             } catch (FalconException e) {
-                throw FalconWebException.newInstanceException(
-                        "Invalid date value for key: " + entry.getKey(), Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException("Invalid date value for key: " + entry.getKey());
             }
         }
     }
@@ -228,14 +225,14 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                     break;
 
                 default:
-                    throw FalconWebException.newInstanceDependencyResult("Instance dependency isn't supported for type:"
-                        + entityType, Response.Status.BAD_REQUEST);
+                    throw FalconWebException.newAPIException("Instance dependency isn't supported for type:"
+                        + entityType);
                 }
             }
 
         } catch (Throwable throwable) {
             LOG.error("Failed to get instance dependencies:", throwable);
-            throw FalconWebException.newInstanceDependencyResult(throwable, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(throwable);
         }
 
         InstanceDependencyResult res = new InstanceDependencyResult(APIResult.Status.SUCCEEDED, "Success!");
@@ -261,7 +258,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
 
         } catch (Throwable e) {
             LOG.error("Failed to get instance summary", e);
-            throw FalconWebException.newInstanceSummaryException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -282,8 +279,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
             return result;
         } catch (Exception e) {
             LOG.error("Failed to get logs for instances", e);
-            throw FalconWebException.newInstanceException(e,
-                    Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -552,7 +548,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
             return wfEngine.getInstanceParams(entityObject, start, end, lifeCycles);
         } catch (Throwable e) {
             LOG.error("Failed to display params of an instance", e);
-            throw FalconWebException.newInstanceException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -578,7 +574,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                     startAndEndDate.first, startAndEndDate.second, props, lifeCycles);
         } catch (Throwable e) {
             LOG.error("Failed to kill instances", e);
-            throw FalconWebException.newInstanceException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -604,7 +600,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                     startAndEndDate.first, startAndEndDate.second, props, lifeCycles);
         } catch (Throwable e) {
             LOG.error("Failed to suspend instances", e);
-            throw FalconWebException.newInstanceException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -630,7 +626,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                     startAndEndDate.first, startAndEndDate.second, props, lifeCycles);
         } catch (Throwable e) {
             LOG.error("Failed to resume instances", e);
-            throw FalconWebException.newInstanceException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -666,20 +662,19 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
             return result;
         } catch (IllegalArgumentException e) { // bad entityType
             LOG.error("Bad Entity Type: {}", entityType);
-            throw FalconWebException.newTriageResultException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         } catch (EntityNotRegisteredException e) { // bad entityName
             LOG.error("Bad Entity Name : {}", entityName);
-            throw FalconWebException.newTriageResultException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         } catch (Throwable e) {
             LOG.error("Failed to triage", e);
-            throw FalconWebException.newTriageResultException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
     private void checkName(String entityName) {
         if (StringUtils.isBlank(entityName)) {
-            throw FalconWebException.newInstanceException("Instance name is mandatory and shouldn't be blank",
-                    Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException("Instance name is mandatory and shouldn't be blank");
         }
     }
 
@@ -831,7 +826,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                     startAndEndDate.first, startAndEndDate.second, props, lifeCycles, isForced);
         } catch (Exception e) {
             LOG.error("Failed to rerun instances", e);
-            throw FalconWebException.newInstanceException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
     //RESUME CHECKSTYLE CHECK ParameterNumberCheck

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/prism/src/main/java/org/apache/falcon/resource/AbstractSchedulableEntityManager.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/AbstractSchedulableEntityManager.java b/prism/src/main/java/org/apache/falcon/resource/AbstractSchedulableEntityManager.java
index 88131f3..18df32f 100644
--- a/prism/src/main/java/org/apache/falcon/resource/AbstractSchedulableEntityManager.java
+++ b/prism/src/main/java/org/apache/falcon/resource/AbstractSchedulableEntityManager.java
@@ -18,6 +18,19 @@
 
 package org.apache.falcon.resource;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.falcon.FalconException;
 import org.apache.falcon.FalconWebException;
@@ -35,22 +48,10 @@ import org.apache.falcon.service.FeedSLAMonitoringService;
 import org.apache.falcon.util.DeploymentUtil;
 import org.apache.falcon.workflow.WorkflowEngineFactory;
 import org.apache.hadoop.security.authorize.AuthorizationException;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * REST resource of allowed actions on Schedulable Entities, Only Process and
  * Feed can have schedulable actions.
@@ -82,12 +83,12 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
             return new APIResult(APIResult.Status.SUCCEEDED, entity + "(" + type + ") scheduled successfully");
         } catch (Throwable e) {
             LOG.error("Unable to schedule workflow", e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
     protected synchronized void scheduleInternal(String type, String entity, Boolean skipDryRun,
-            Map<String, String> properties) throws FalconException, AuthorizationException {
+                                 Map<String, String> properties) throws FalconException, AuthorizationException {
 
         checkSchedulableEntity(type);
         Entity entityObj = null;
@@ -111,7 +112,7 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
     }
 
     public static void validateSlaParams(String entityType, String entityName, String start, String end,
-                                  String colo) throws FalconException {
+                                         String colo) throws FalconException {
         EntityType type = EntityType.getEnum(entityType);
         if (type != EntityType.FEED) {
             throw new ValidationException("SLA monitoring is not supported for: " + type);
@@ -169,7 +170,7 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
                 }
             }
         } catch (FalconException e) {
-            throw FalconWebException.newInstanceException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
         SchedulableEntityInstanceResult result = new SchedulableEntityInstanceResult(APIResult.Status.SUCCEEDED,
                 "Success!");
@@ -200,7 +201,7 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
                     entity.getName() + "(" + type + ") scheduled successfully");
         } catch (Throwable e) {
             LOG.error("Unable to submit and schedule ", e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -227,7 +228,7 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
             return new APIResult(APIResult.Status.SUCCEEDED, entity + "(" + type + ") suspended successfully");
         } catch (Throwable e) {
             LOG.error("Unable to suspend entity", e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -255,7 +256,7 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
             return new APIResult(APIResult.Status.SUCCEEDED, entity + "(" + type + ") resumed successfully");
         } catch (Throwable e) {
             LOG.error("Unable to resume entity", e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -301,7 +302,7 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
             colo = ((Cluster) configStore.get(EntityType.CLUSTER, cluster)).getColo();
         } catch (Exception e) {
             LOG.error("Failed to get entities", e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
 
         List<EntitySummaryResult.EntitySummary> entitySummaries = new ArrayList<EntitySummaryResult.EntitySummary>();
@@ -358,7 +359,7 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
             }
         } catch (Throwable e) {
             LOG.error("Touch failed", e);
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
         return new APIResult(APIResult.Status.SUCCEEDED, result.toString());
     }
@@ -367,9 +368,8 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
     private void validateTypeForEntitySummary(String type) {
         EntityType entityType = EntityType.getEnum(type);
         if (!entityType.isSchedulable()) {
-            throw FalconWebException.newException("Invalid entity type " + type
-                + " for EntitySummary API. Valid options are feed or process",
-                Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException("Invalid entity type " + type
+                            + " for EntitySummary API. Valid options are feed or process");
         }
     }
     //RESUME CHECKSTYLE CHECK ParameterNumberCheck

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/prism/src/main/java/org/apache/falcon/resource/channel/HTTPChannel.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/channel/HTTPChannel.java b/prism/src/main/java/org/apache/falcon/resource/channel/HTTPChannel.java
index 41be13f..1b53120 100644
--- a/prism/src/main/java/org/apache/falcon/resource/channel/HTTPChannel.java
+++ b/prism/src/main/java/org/apache/falcon/resource/channel/HTTPChannel.java
@@ -119,8 +119,8 @@ public class HTTPChannel extends AbstractChannel {
             } else if (response.getClientResponseStatus().getStatusCode()
                     == Response.Status.BAD_REQUEST.getStatusCode()) {
                 LOG.error("Request failed: {}", response.getClientResponseStatus().getStatusCode());
-                throw FalconWebException.newInstanceException(response.
-                        getEntity(APIResult.class).getMessage(), Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException(response.
+                        getEntity(APIResult.class).getMessage());
             } else {
                 LOG.error("Request failed: {}", response.getClientResponseStatus().getStatusCode());
                 throw new FalconException(response.getEntity(String.class));

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/prism/src/main/java/org/apache/falcon/resource/metadata/LineageMetadataResource.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/metadata/LineageMetadataResource.java b/prism/src/main/java/org/apache/falcon/resource/metadata/LineageMetadataResource.java
index 8c5346f..1b57e67 100644
--- a/prism/src/main/java/org/apache/falcon/resource/metadata/LineageMetadataResource.java
+++ b/prism/src/main/java/org/apache/falcon/resource/metadata/LineageMetadataResource.java
@@ -92,7 +92,7 @@ public class LineageMetadataResource extends AbstractMetadataResource {
             GraphUtils.dump(getGraph(), file);
             return Response.ok().build();
         } catch (Exception e) {
-            throw FalconWebException.newException(e, Response.Status.INTERNAL_SERVER_ERROR);
+            throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR);
         }
     }
 
@@ -125,17 +125,15 @@ public class LineageMetadataResource extends AbstractMetadataResource {
                 }
             } catch (Exception e) {
                 LOG.error("Error while fetching entity lineage: ", e);
-                throw FalconWebException.newException(e, Response.Status.INTERNAL_SERVER_ERROR);
+                throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR);
             }
 
             if (processes.isEmpty()) {
-                throw FalconWebException.newException("No processes belonging to pipeline " + pipeline,
-                        Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException("No processes belonging to pipeline " + pipeline);
             }
             return Response.ok(buildJSONGraph(processes)).build();
         } else {
-            throw FalconWebException.newException("Pipeline name can not be blank",
-                    Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException("Pipeline name can not be blank");
         }
     }
 
@@ -155,7 +153,7 @@ public class LineageMetadataResource extends AbstractMetadataResource {
             JSONObject response = buildJSONResponse(getGraph().getVertices());
             return Response.ok(response).build();
         } catch (JSONException e) {
-            throw FalconWebException.newException(e, Response.Status.INTERNAL_SERVER_ERROR);
+            throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR);
         }
     }
 
@@ -181,7 +179,7 @@ public class LineageMetadataResource extends AbstractMetadataResource {
                     vertex, getVertexIndexedKeys(), GraphSONMode.NORMAL));
             return Response.ok(response).build();
         } catch (JSONException e) {
-            throw FalconWebException.newException(e, Response.Status.INTERNAL_SERVER_ERROR);
+            throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR);
         }
     }
 
@@ -224,7 +222,7 @@ public class LineageMetadataResource extends AbstractMetadataResource {
             response.put(TOTAL_SIZE, vertexProperties.size());
             return Response.ok(response).build();
         } catch (JSONException e) {
-            throw FalconWebException.newException(e, Response.Status.INTERNAL_SERVER_ERROR);
+            throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR);
         }
     }
 
@@ -429,7 +427,7 @@ public class LineageMetadataResource extends AbstractMetadataResource {
             return Response.ok(response).build();
 
         } catch (JSONException e) {
-            throw FalconWebException.newException(e, Response.Status.INTERNAL_SERVER_ERROR);
+            throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR);
         }
     }
 
@@ -461,7 +459,7 @@ public class LineageMetadataResource extends AbstractMetadataResource {
                     edge, getEdgeIndexedKeys(), GraphSONMode.NORMAL));
             return Response.ok(response).build();
         } catch (JSONException e) {
-            throw FalconWebException.newException(e, Response.Status.INTERNAL_SERVER_ERROR);
+            throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/prism/src/main/java/org/apache/falcon/resource/metadata/MetadataDiscoveryResource.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/metadata/MetadataDiscoveryResource.java b/prism/src/main/java/org/apache/falcon/resource/metadata/MetadataDiscoveryResource.java
index 60c1089..0f7701c 100644
--- a/prism/src/main/java/org/apache/falcon/resource/metadata/MetadataDiscoveryResource.java
+++ b/prism/src/main/java/org/apache/falcon/resource/metadata/MetadataDiscoveryResource.java
@@ -85,7 +85,7 @@ public class MetadataDiscoveryResource extends AbstractMetadataResource {
             response.put(TOTAL_SIZE, dimensionValues.length());
             return Response.ok(response).build();
         } catch (JSONException e) {
-            throw FalconWebException.newException(e, Response.Status.INTERNAL_SERVER_ERROR);
+            throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR);
         }
     }
 
@@ -124,7 +124,7 @@ public class MetadataDiscoveryResource extends AbstractMetadataResource {
             vertexProperties.put("outVertices", getAdjacentVerticesJson(outEdges, Direction.IN));
 
         } catch (JSONException e) {
-            throw FalconWebException.newException(e, Response.Status.INTERNAL_SERVER_ERROR);
+            throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR);
         }
 
         return Response.ok(vertexProperties).build();

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/prism/src/main/java/org/apache/falcon/resource/proxy/BufferedRequest.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/proxy/BufferedRequest.java b/prism/src/main/java/org/apache/falcon/resource/proxy/BufferedRequest.java
index 85041f9..4e73d5d 100644
--- a/prism/src/main/java/org/apache/falcon/resource/proxy/BufferedRequest.java
+++ b/prism/src/main/java/org/apache/falcon/resource/proxy/BufferedRequest.java
@@ -85,7 +85,7 @@ public class BufferedRequest implements HttpServletRequest {
             };
             stream.mark(10 * 1024 * 1024);
         } catch (IOException e) {
-            throw FalconWebException.newException(e, Response.Status.INTERNAL_SERVER_ERROR);
+            throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/prism/src/main/java/org/apache/falcon/resource/proxy/InstanceManagerProxy.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/proxy/InstanceManagerProxy.java b/prism/src/main/java/org/apache/falcon/resource/proxy/InstanceManagerProxy.java
index 801bd10..0c6be2d 100644
--- a/prism/src/main/java/org/apache/falcon/resource/proxy/InstanceManagerProxy.java
+++ b/prism/src/main/java/org/apache/falcon/resource/proxy/InstanceManagerProxy.java
@@ -18,6 +18,23 @@
 
 package org.apache.falcon.resource.proxy;
 
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
 import org.apache.falcon.FalconException;
 import org.apache.falcon.FalconRuntimException;
 import org.apache.falcon.FalconWebException;
@@ -33,26 +50,10 @@ import org.apache.falcon.resource.InstancesSummaryResult;
 import org.apache.falcon.resource.TriageResult;
 import org.apache.falcon.resource.channel.Channel;
 import org.apache.falcon.resource.channel.ChannelFactory;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * A proxy implementation of the entity instance operations.
  */
@@ -625,12 +626,12 @@ public class InstanceManagerProxy extends AbstractInstanceManager {
                 } catch (Throwable e) {
                     LOG.error("Failed to fetch results for colo:{}", colo, e);
                     results.put(colo, getResultInstance(APIResult.Status.FAILED,
-                        e.getClass().getName() + "::" + e.getMessage()));
+                            e.getClass().getName() + "::" + e.getMessage()));
                 }
             }
             T finalResult = consolidateResult(results, clazz);
             if (finalResult.getStatus() != APIResult.Status.SUCCEEDED) {
-                throw FalconWebException.newException(finalResult, Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException(finalResult.getMessage());
             } else {
                 return finalResult;
             }

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java b/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
index dfed5af..f721bd0 100644
--- a/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
+++ b/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
@@ -18,6 +18,25 @@
 
 package org.apache.falcon.resource.proxy;
 
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.falcon.FalconException;
 import org.apache.falcon.FalconRuntimException;
@@ -39,25 +58,6 @@ import org.apache.falcon.resource.channel.Channel;
 import org.apache.falcon.resource.channel.ChannelFactory;
 import org.apache.falcon.util.DeploymentUtil;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * A proxy implementation of the schedulable entity operations.
  */
@@ -124,10 +124,10 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
         try {
             validateSlaParams(entityType, entityName, start, end, colo);
         } catch (Exception e) {
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
         return new EntityProxy<SchedulableEntityInstanceResult>(entityType, entityName,
-            SchedulableEntityInstanceResult.class) {
+                SchedulableEntityInstanceResult.class) {
             @Override
             protected Set<String> getColosToApply() {
                 return getApplicableColos(entityType, entityName);
@@ -191,8 +191,8 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
         // If the submitted entity is a cluster, ensure its spec. has one of the valid colos
         String colo = ((Cluster) entity).getColo();
         if (!applicableColos.contains(colo)) {
-            throw FalconWebException.newException("The colo mentioned in the cluster specification, "
-                    + colo + ", is not listed in Prism runtime.", Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException("The colo mentioned in the cluster specification, "
+                    + colo + ", is not listed in Prism runtime.");
         }
     }
 
@@ -203,7 +203,7 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
             request.getInputStream().reset();
             return entity;
         } catch (Exception e) {
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
     }
 
@@ -228,7 +228,7 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
             entity = deserializeEntity(bufferedRequest.getInputStream(), entityType);
             bufferedRequest.getInputStream().reset();
         } catch (Exception e) {
-            throw FalconWebException.newException("Unable to parse the request", Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException("Unable to parse entity definition");
         }
         return new EntityProxy(type, entity.getName()) {
             @Override
@@ -274,7 +274,7 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
                     return new APIResult(APIResult.Status.SUCCEEDED,
                             entity + "(" + type + ") doesn't exist. Nothing to do");
                 } catch (FalconException e) {
-                    throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+                    throw FalconWebException.newAPIException(e);
                 }
             }
 
@@ -779,7 +779,7 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
 
             T finalResult = consolidateResult(results, clazz);
             if (finalResult.getStatus() == APIResult.Status.FAILED) {
-                throw FalconWebException.newException(finalResult, Response.Status.BAD_REQUEST);
+                throw FalconWebException.newAPIException(finalResult.getMessage());
             } else {
                 return finalResult;
             }

http://git-wip-us.apache.org/repos/asf/falcon/blob/2cbf5030/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java b/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
index 0c7786f..8f8f56f 100644
--- a/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
+++ b/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
@@ -18,11 +18,6 @@
 
 package org.apache.falcon.resource;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.falcon.FalconWebException;
-import org.apache.falcon.monitors.Dimension;
-import org.apache.falcon.monitors.Monitored;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DefaultValue;
@@ -34,7 +29,11 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.falcon.FalconWebException;
+import org.apache.falcon.monitors.Dimension;
+import org.apache.falcon.monitors.Monitored;
 
 /**
  * Entity management operations as REST API for feed and process.
@@ -67,7 +66,7 @@ public class SchedulableEntityManager extends AbstractSchedulableEntityManager {
         try {
             validateSlaParams(entityType, entityName, start, end, colo);
         } catch (Exception e) {
-            throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
+            throw FalconWebException.newAPIException(e);
         }
         return super.getFeedSLAMissPendingAlerts(entityName, start, end, colo);
     }


Mime
View raw message