Skip to content

Commit

Permalink
#39 Customize error message for security exception
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Dec 18, 2017
1 parent c67e9c8 commit d02dfce
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/org/elastic4play/ErrorHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import play.api.mvc.{ RequestHeader, ResponseHeader, Result, Results }
import org.elasticsearch.client.transport.NoNodeAvailableException
import org.elasticsearch.index.IndexNotFoundException
import org.elasticsearch.index.query.QueryShardException
import org.elasticsearch.ElasticsearchSecurityException

import org.elastic4play.JsonFormat.attributeCheckingExceptionWrites

Expand All @@ -36,6 +37,7 @@ class ErrorHandler extends HttpErrorHandler {
case SearchError(message, cause) Some(Status.BAD_REQUEST Json.obj("type" "SearchError", "message" s"$message (${cause.getMessage})"))
case ace: AttributeCheckingError Some(Status.BAD_REQUEST Json.toJson(ace))
case iae: IllegalArgumentException Some(Status.BAD_REQUEST Json.obj("type" "IllegalArgument", "message" iae.getMessage))
case _: ElasticsearchSecurityException Some(Status.INTERNAL_SERVER_ERROR Json.obj("type" "NoNodeAvailable", "message" "ElasticSearch cluster access denied, check your authentication settings"))
case _: NoNodeAvailableException Some(Status.INTERNAL_SERVER_ERROR Json.obj("type" "NoNodeAvailable", "message" "ElasticSearch cluster is unreachable"))
case CreateError(_, message, attributes) Some(Status.INTERNAL_SERVER_ERROR Json.obj("type" "CreateError", "message" message, "object" attributes))
case ErrorWithObject(tpe, message, obj) Some(Status.BAD_REQUEST Json.obj("type" tpe, "message" message, "object" obj))
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version := "1.4.1"
version := "1.4.2-SNAPSHOT"

0 comments on commit d02dfce

Please sign in to comment.