I use Scala + Lift Web Framework + MongoDB for a bunch of applications. In some instances, I need to respond with a JSON error message to the client making the request to display an internationalized error message.
An error message will generally be a simple JSON:
val errorMessage = ("error" -> "some error message");
This message would then be served via net.liftweb.rest.RestHelper
with yield requestParam: JValue
. I use for comprehensions
to check for errors and return these JValue
s.
What is the best practice to store these messages in Scala(with internationalization in mind)?
well, doesn't the principle "let the developer decide" apply?
I mean, AFAIK, there is no central way to do that. Do any way you want. For example,
(S ? "error") -> (S ? "my.error.reason123")