Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify exception on timeout #849

Merged
merged 1 commit into from Mar 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion monix-eval/shared/src/main/scala/monix/eval/Task.scala
Expand Up @@ -2212,7 +2212,16 @@ sealed abstract class Task[+A] extends Serializable {
* task emitting any item.
*/
final def timeout(after: FiniteDuration): Task[A] =
timeoutTo(after, raiseError(new TimeoutException(s"Task timed-out after $after of inactivity")))
timeoutWith(after, new TimeoutException(s"Task timed-out after $after of inactivity"))

/** Returns a Task that mirrors the source Task but that triggers a
* specified `Exception` in case the given duration passes
* without the task emitting any item.
* @param exception The `Exception` to throw after given duration
* passes
*/
final def timeoutWith(after: FiniteDuration, exception: Exception): Task[A] =
timeoutTo(after, raiseError(exception))

/** Returns a Task that mirrors the source Task but switches to the
* given backup Task in case the given duration passes without the
Expand Down