usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject incubator-usergrid git commit: Created a NullPointerExceptionMapper that gets caught in the rest tier.
Date Thu, 02 Apr 2015 22:55:13 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/NullPointerMapper [created] ec7b5879d


Created a NullPointerExceptionMapper that gets caught in the rest tier.


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

Branch: refs/heads/NullPointerMapper
Commit: ec7b5879d246ea793fcb5d4edd408fb1b30b886e
Parents: d20267b
Author: GERey <greyes@apigee.com>
Authored: Thu Apr 2 15:54:40 2015 -0700
Committer: GERey <greyes@apigee.com>
Committed: Thu Apr 2 15:54:40 2015 -0700

----------------------------------------------------------------------
 .../exceptions/NullPointerExceptionMapper.java  | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ec7b5879/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/NullPointerExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/NullPointerExceptionMapper.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/NullPointerExceptionMapper.java
new file mode 100644
index 0000000..d19d217
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/NullPointerExceptionMapper.java
@@ -0,0 +1,25 @@
+package org.apache.usergrid.rest.exceptions;
+
+
+import javax.ws.rs.core.Response;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
+
+
+/**
+ * Wraps null pointer exceptions to only return 500's.
+ */
+public class NullPointerExceptionMapper extends AbstractExceptionMapper<NullPointerException>
{
+    private static final Logger logger = LoggerFactory.getLogger( NullPointerExceptionMapper.class
);
+
+    @Override
+    public Response toResponse( NullPointerException e ) {
+
+        logger.error( "Illegal argument was passed, returning bad request to user", e );
+
+        return toResponse( INTERNAL_SERVER_ERROR, e );
+    }
+}


Mime
View raw message