3 ms·
This isn't a binary choice. In Scala, you can use Throwable or Exception as your error type with Either: Either[Throwable, Option[Foobar]] The type Try[T] i
by kagakuninja 3y ago
This isn't a binary choice. In Scala, you can use Throwable or Exception as your error type with Either:
Either[Throwable, Option[Foobar]]
The type Try[T] is essentially Either[Throwable, T]
Either[Throwable, T], Try, as well as IO from Cats Effect give you the stack traces that you expect from conventional Java style, with the superior option of programming in the monadic / "railway" style. Try also interfaces nicely with Java libraries: val result: Try[Foobar] = Try(javaFunction).