scalaz / ioeffect

An effect monad for Scalaz 7.2
Other
55 stars 9 forks source link

unwanted printlns in the default handler #54

Closed fommil closed 6 years ago

fommil commented 6 years ago

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.

fommil commented 6 years ago

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
    }
  }
ktonga commented 6 years ago

I went with:

trait MuteRTS extends RTS {
  override def defaultHandler[E]: Throwable => IO[E, Unit] = _ => IO.unit
}