activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1230606 - in /activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources: JaxrsExceptionMapper.scala Support.scala
Date Thu, 12 Jan 2012 15:59:19 GMT
Author: chirino
Date: Thu Jan 12 15:59:19 2012
New Revision: 1230606

URL: http://svn.apache.org/viewvc?rev=1230606&view=rev
Log:
More error reporting tweaks.

Modified:
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/JaxrsExceptionMapper.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/JaxrsExceptionMapper.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/JaxrsExceptionMapper.scala?rev=1230606&r1=1230605&r2=1230606&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/JaxrsExceptionMapper.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/JaxrsExceptionMapper.scala
Thu Jan 12 15:59:19 2012
@@ -42,6 +42,7 @@ class JaxrsExceptionMapper extends Excep
     http_request.getRequestURI + Option(query).map("?"+_).getOrElse("")
   }
 
+  @Produces(Array(APPLICATION_JSON, APPLICATION_XML, TEXT_XML))
   def toResponse(error: Throwable): Response = {
     def response(status: Response.Status, msg: String=null) = {
       val response = Response.status(status)

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala?rev=1230606&r1=1230605&r2=1230606&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala
Thu Jan 12 15:59:19 2012
@@ -77,10 +77,23 @@ abstract class Resource(parent:Resource=
     this.http_request = other.http_request
   }
 
-  def create_result(value: Response.Status, message: Any): WebApplicationException = {
-    val response = Response.status(value)
-    if (message != null) {
-      response.entity(message)
+  def requested_uri = {
+    val query = http_request.getQueryString
+    http_request.getRequestURI + Option(query).map("?"+_).getOrElse("")
+  }
+
+  def create_result(status: Response.Status, message: Any): WebApplicationException = {
+    val response = Response.status(status)
+    message match {
+      case null =>
+      case message:String =>
+        val e = new ErrorDTO
+        e.code = "%d: %s".format(status.getStatusCode, status.getReasonPhrase)
+        e.message = message
+        e.resource = requested_uri
+        response.entity(e)
+      case x:AnyRef =>
+        response.entity(message)
     }
     new WebApplicationException(response.build).fillInStackTrace().asInstanceOf[WebApplicationException]
   }



Mime
View raw message