aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuicommon/error/ErrorCode.scala
diff options
context:
space:
mode:
authorKseniya Tomskikh <ktomskih@datamonsters.co>2017-10-30 16:29:46 +0700
committerGitHub <noreply@github.com>2017-10-30 16:29:46 +0700
commit604fbf0a7a082bc440c0778abd6f90005b210c16 (patch)
treefd846d42448b2d3f432056898f0c3433475ea0da /src/main/scala/xyz/driver/pdsuicommon/error/ErrorCode.scala
parent8811d60442d060097027b33784ece9a704458e1d (diff)
parentd92a2795a02b9711aa9aed92a770f85377b31460 (diff)
downloadrest-query-604fbf0a7a082bc440c0778abd6f90005b210c16.tar.gz
rest-query-604fbf0a7a082bc440c0778abd6f90005b210c16.tar.bz2
rest-query-604fbf0a7a082bc440c0778abd6f90005b210c16.zip
Merge pull request #54 from drivergroup/PDSUI-2336v0.11.0
PDSUI-2336 Cleanup
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuicommon/error/ErrorCode.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuicommon/error/ErrorCode.scala15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/scala/xyz/driver/pdsuicommon/error/ErrorCode.scala b/src/main/scala/xyz/driver/pdsuicommon/error/ErrorCode.scala
index 5574c01..748e76a 100644
--- a/src/main/scala/xyz/driver/pdsuicommon/error/ErrorCode.scala
+++ b/src/main/scala/xyz/driver/pdsuicommon/error/ErrorCode.scala
@@ -1,7 +1,6 @@
package xyz.driver.pdsuicommon.error
-import play.api.libs.functional.syntax._
-import play.api.libs.json.{Format, Reads, Writes}
+import xyz.driver.core.json.EnumJsonFormat
@SuppressWarnings(Array("org.wartremover.warts.Enumeration"))
object ErrorCode extends Enumeration {
@@ -9,9 +8,13 @@ object ErrorCode extends Enumeration {
type ErrorCode = Value
val Unspecified = Value(1)
- private val fromJsonReads: Reads[ErrorCode] = Reads.of[Int].map(ErrorCode.apply)
- private val toJsonWrites: Writes[ErrorCode] = Writes.of[Int].contramap(_.id)
-
- implicit val jsonFormat: Format[ErrorCode] = Format(fromJsonReads, toJsonWrites)
+ implicit val jsonFormat = new EnumJsonFormat[ErrorCode](
+ "200" -> ErrorCode.Value(200),
+ "400" -> ErrorCode.Value(400),
+ "401" -> ErrorCode.Value(401),
+ "403" -> ErrorCode.Value(403),
+ "404" -> ErrorCode.Value(404),
+ "500" -> ErrorCode.Value(500)
+ )
}