Skip to content

Commit

Permalink
DEX-1285 added HasErrorCode trait (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
JennaWestenra authored Aug 13, 2021
1 parent 455350e commit 90ebdd2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions dex/src/main/scala/com/wavesplatform/dex/error/MatcherError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 90ebdd2

Please sign in to comment.