From 90ebdd227daedc34fd1184166e0171744a38c189 Mon Sep 17 00:00:00 2001 From: JennaWestenra <78524706+JennaWestenra@users.noreply.github.com> Date: Fri, 13 Aug 2021 16:13:43 +0600 Subject: [PATCH] DEX-1285 added HasErrorCode trait (#617) --- .../com/wavesplatform/dex/error/MatcherError.scala | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dex/src/main/scala/com/wavesplatform/dex/error/MatcherError.scala b/dex/src/main/scala/com/wavesplatform/dex/error/MatcherError.scala index 41b09c9447..d4ca63b056 100644 --- a/dex/src/main/scala/com/wavesplatform/dex/error/MatcherError.scala +++ b/dex/src/main/scala/com/wavesplatform/dex/error/MatcherError.scala @@ -14,12 +14,19 @@ import com.wavesplatform.dex.error.Implicits._ import com.wavesplatform.dex.settings.{DeviationsSettings, OrderRestrictionsSettings} import play.api.libs.json.{JsObject, Json, OWrites} +sealed trait HasErrorCode { + val code: Int +} + //helper for companion objects of MatcherError children in order to reduce boilerplate -sealed abstract class MatcherErrorCodeProvider(obj: Entity, part: Entity, cls: Class) { - final val code = MatcherError.mkCode(obj, part, cls) +sealed abstract class MatcherErrorCodeProvider(obj: Entity, part: Entity, cls: Class) extends HasErrorCode { + final override val code = MatcherError.mkCode(obj, part, cls) } -sealed abstract class MatcherError(val code: Int, val message: MatcherErrorMessage) extends Product with Serializable { +sealed abstract class MatcherError(override val code: Int, val message: MatcherErrorMessage) + extends Product + with Serializable + with HasErrorCode { def this(obj: Entity, part: Entity, cls: Class, message: MatcherErrorMessage) = this( MatcherError.mkCode(obj, part, cls), message