It depends on how you approach error propagation and handling in general in your application. There’s been some discussion about that - possible approaches include exceptions, Option
, Either
, Try
, Validation
, and further considerations will surface once (side) effects and/or async processing are involved. I don’t think there’s a clear-cut consensus regarding the “proper Scala way”, other than that using raw exceptions probably isn’t it.
As for null
, in a Scala project I’d only expect this when interfacing with Java code - there I’d wrap it with Option#apply()
and handle the None
case as a failure. With StringUtils
, I’d assume you’re validating user input, so Either
or Validation
might be appropriate.