You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
40 lines
1.3 KiB
package wow.doge.mygame
|
|
|
|
import java.util.concurrent.TimeoutException
|
|
|
|
import cats.data.Reader
|
|
import monix.bio.IO
|
|
import wow.doge.mygame.utils.wrappers.jme.AssetManager
|
|
import wow.doge.mygame.utils.wrappers.jme.CollisionShapeFactory
|
|
import wow.doge.mygame.utils.wrappers.jme.NodeWrapper2
|
|
|
|
sealed trait AppError
|
|
object AppError {
|
|
final case class TimeoutError(reason: String) extends AppError
|
|
object TimeoutError {
|
|
def reader =
|
|
Reader[Throwable, TimeoutError] {
|
|
case ex: TimeoutException => TimeoutError(ex.getMessage)
|
|
}
|
|
def from: PartialFunction[Throwable, IO[TimeoutError, Nothing]] = {
|
|
case ex: TimeoutException => IO.raiseError(TimeoutError(ex.getMessage))
|
|
}
|
|
}
|
|
final case class DummyError(reason: String) extends AppError
|
|
object DummyError {
|
|
def reader =
|
|
Reader[Throwable, DummyError] {
|
|
case ex: NullPointerException => DummyError(ex.getMessage)
|
|
}
|
|
}
|
|
final case class AssetManagerError(error: AssetManager.Error) extends AppError
|
|
final case class AppNodeError(error: NodeWrapper2.Error) extends AppError
|
|
final case class CollisionShapeCreationFailed(
|
|
err: CollisionShapeFactory.Error
|
|
) extends AppError
|
|
|
|
def fromThrowable: PartialFunction[Throwable, IO[AppError, Nothing]] = {
|
|
case ex: TimeoutException => IO.raiseError(TimeoutError(ex.getMessage))
|
|
|
|
}
|
|
}
|