September 2018
Intermediate to advanced
398 pages
9h 43m
English
The next step is to add new types of errors that will be returned in ValidateNel when some arguments are wrong. We need to change RetCalcError.scala as follows:
object RetCalcError { type RetCalcResult[A] = ValidatedNel[RetCalcError, A] case class MoreExpensesThanIncome(income: Double, expenses: Double) extends RetCalcError(...) case class ReturnMonthOutOfBounds(month: Int, maximum: Int) extends RetCalcError(...) case class InvalidNumber(name: String, value: String) extends RetCalcError( s"Invalid number for $name: $value") case class InvalidArgument(name: String, value: String, expectedFormat: String) extends RetCalcError( s"Invalid format for $name. Expected: $expectedFormat, actual: $value")}
Here, ...
Read now
Unlock full access