raiseError constructs an effectful computation representing a specified Throwable rather than throwing it immediately. It belongs to MonadThrow, which extends Monad with explicit error raising and handling. section 15.3.2
The operation in MonadThrow
trait MonadThrow[F[_]] extends Monad[F]: def raiseError[A](t: Throwable): F[A] The result type remains F[A], so the failure is represented inside the effect and can later participate in attempt or handleErrorWith.
Stream and Pull add raiseError constructors so computations can explicitly fail during incremental processing. The operation also supports combinators such as onComplete, which can run a final stream and then re-raise the original error. section 15.3.2
