Browse Source

server: Add TransactionError

scalafmt-draft
Alexis Hernandez 7 years ago
parent
commit
5eae17f452
  1. 24
      server/app/com/xsn/explorer/errors/transactionErrors.scala
  2. 3
      server/conf/messages

24
server/app/com/xsn/explorer/errors/transactionErrors.scala

@ -0,0 +1,24 @@
package com.xsn.explorer.errors
import com.alexitc.playsonify.models.{FieldValidationError, InputValidationError, PublicError}
import play.api.i18n.{Lang, MessagesApi}
sealed trait TransactionError
case object TransactionFormatError extends TransactionError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.transaction.format")
val error = FieldValidationError("transactionId", message)
List(error)
}
}
case object TransactionNotFoundError extends TransactionError with InputValidationError {
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = {
val message = messagesApi("error.transaction.notFound")
val error = FieldValidationError("transactionId", message)
List(error)
}
}

3
server/conf/messages

@ -1,3 +1,6 @@
# https://www.playframework.com/documentation/latest/ScalaI18N
xsn.server.unexpectedError=Unexpected error from the XSN network
error.transaction.format=Invalid transaction format
error.transaction.notFound=Transaction not found

Loading…
Cancel
Save