You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@s2graph.apache.org by da...@apache.org on 2016/01/04 07:40:54 UTC
[21/46] incubator-s2graph git commit: Change response format on
BadRequest
Change response format on BadRequest
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/77b5afd7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/77b5afd7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/77b5afd7
Branch: refs/heads/feature/test_daewon
Commit: 77b5afd755771a7c09f969fb014b21f1211fe415
Parents: d7b48a6
Author: daewon <bl...@gmail.com>
Authored: Wed Dec 23 15:31:37 2015 +0900
Committer: daewon <bl...@gmail.com>
Committed: Wed Dec 23 15:31:37 2015 +0900
----------------------------------------------------------------------
s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala | 6 +++++-
.../main/scala/com/kakao/s2graph/core/rest/RestCaller.scala | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/77b5afd7/s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala b/s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala
index c3f3359..83e3a71 100644
--- a/s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala
+++ b/s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala
@@ -1,5 +1,6 @@
package com.kakao.s2graph.core
+import com.kakao.s2graph.core.GraphExceptions.BadQueryException
import com.kakao.s2graph.core.mysqls.{ColumnMeta, Label, ServiceColumn, LabelMeta}
import com.kakao.s2graph.core.types.{InnerValLike, InnerVal}
import com.kakao.s2graph.core.utils.logger
@@ -13,7 +14,10 @@ object PostProcess extends JSONParser {
*/
val timeoutResults = Json.obj("size" -> 0, "results" -> Json.arr(), "isTimeout" -> true)
val emptyResults = Json.obj("size" -> 0, "results" -> Json.arr(), "isEmpty" -> true)
- def badRequestResults(ex: => Exception) = Json.obj("message" -> ex.getMessage)
+ def badRequestResults(ex: => Exception) = ex match {
+ case ex: BadQueryException => Json.obj("message" -> ex.msg)
+ case _ => Json.obj("message" -> ex.getMessage)
+ }
val SCORE_FIELD_NAME = "scoreSum"
val reservedColumns = Set("cacheRemain", "from", "to", "label", "direction", "_timestamp", "timestamp", "score", "props")
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/77b5afd7/s2core/src/main/scala/com/kakao/s2graph/core/rest/RestCaller.scala
----------------------------------------------------------------------
diff --git a/s2core/src/main/scala/com/kakao/s2graph/core/rest/RestCaller.scala b/s2core/src/main/scala/com/kakao/s2graph/core/rest/RestCaller.scala
index 3278ece..bef1dec 100644
--- a/s2core/src/main/scala/com/kakao/s2graph/core/rest/RestCaller.scala
+++ b/s2core/src/main/scala/com/kakao/s2graph/core/rest/RestCaller.scala
@@ -155,7 +155,7 @@ class RestCaller(graph: Graph)(implicit ec: ExecutionContext) {
Try(Json.parse(body)).recover {
case e: Exception =>
- throw new RuntimeException(s"wrong or missing template parameter: ${e.getMessage}")
+ throw new BadQueryException(s"wrong or missing template parameter: ${e.getMessage.takeWhile(_ != '\n')}")
} get
}