unwanted printlns in the default handler
fommil opened this issue · comments
>>= commented
I'm using IO.syncThrowable
to invoke a legacy method that can throw an exception.
But even though that's supposed to capture the execption as a valid Task
error, not an unexpected exception, I'm still getting the stacktrace dumped to the screen with
scalaz.ioeffect.Errors$UnhandledError: An error was not handled by a fiber:
I can try to minimise it with an example if this is difficult to see by inspection.
>>= commented
misunderstanding, if the error makes it to unsafePerformIO
, this will be printed.
to match cats behaviour
implicit class TaskOps[A](val io: Task[A]) extends AnyVal {
def unsafeRunSync(): A = ZIO.unsafePerformIO(io.attempt[Void]) match {
case -\/(underlying) => throw underlying
case \/-(a) => a
}
}
Gastón Tonietti commented
I went with:
trait MuteRTS extends RTS {
override def defaultHandler[E]: Throwable => IO[E, Unit] = _ => IO.unit
}