This is my current unsatisfactory solution to the problem of manipulating the values passed to the subclass constructor before passing onto the superclass constructor,
class MissingItemsException(items: Set[String], itemsCategory: String)
extends RuntimeException(MissingItemsException.makeMessage(items, itemsCategory))
private object MissingItemsException {
private def makeMessage(items: Set[String], itemsCategory: String): String = {
/* Format set as ['α','β','γ'] */
val Items = items mkString ("['", "','", "']")
"the following items %s were missing from '%s'" format (items, itemsCategory)
}
}
Is there a way of factoring out the transformation so that the transformation code remains close to the point of use while keeping the code legible?