From 5eae17f45249a049fd6d7f42133d59d3eb9ed1a0 Mon Sep 17 00:00:00 2001 From: Alexis Hernandez Date: Sat, 10 Mar 2018 22:17:49 -0600 Subject: [PATCH] server: Add TransactionError --- .../explorer/errors/transactionErrors.scala | 24 +++++++++++++++++++ server/conf/messages | 3 +++ 2 files changed, 27 insertions(+) create mode 100644 server/app/com/xsn/explorer/errors/transactionErrors.scala diff --git a/server/app/com/xsn/explorer/errors/transactionErrors.scala b/server/app/com/xsn/explorer/errors/transactionErrors.scala new file mode 100644 index 0000000..d3d8627 --- /dev/null +++ b/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) + } +} diff --git a/server/conf/messages b/server/conf/messages index c337060..299629c 100644 --- a/server/conf/messages +++ b/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