More idiomatic Scala error handling