Reputation: 11308
There should be something simple here, though I'm completely missing it, since I'm noob in Scala and Play. Here's the code:
case class ExceptionInfo(ExceptionType: String, Message: String, StackTrace: Seq[String])
object ExceptionInfo
{
val excInfoParser = {
get[String]("ExceptionInfo.ExceptionType") ~
get[String]("Message") ~
get[String]("ExceptionInfo.StackTrace") map {
case ExceptionType ~ Message ~ StackTrace => ExceptionInfo(ExceptionType, Message, StackTrace.split("\r\n"))
}
}
}
This doesn't compile, with following output:
Description Resource Path Location Type
not found: value ExceptionType Application.scala /testme/app/controllers line 40 Scala Problem
not found: value Message Application.scala /testme/app/controllers line 40 Scala Problem
not found: value StackTrace Application.scala /testme/app/controllers line 40 Scala Problem
not found: value ExceptionType Application.scala /testme/app/controllers line 40 Scala Problem
Thanks in advance!
Upvotes: 1
Views: 302
Reputation: 10657
Should work when you name the variables in lowercase:
case exceptionType ~ message ~ stackTrace => ExceptionInfo(exceptionType, message, stackTrace.split("\r\n"))
The lowercase is what distinguishes variables to be bound to (what you're looking for) from constants to be matched against. See here and here for more.
Upvotes: 2