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 1 commit into from Mar 25, 2019


None yet
3 participants
Copy link

commented Mar 24, 2019

This PR allows you specify an exception when calling .timout on a Task. The reason why this PR is being made is that in one of our company projects using Monix we make heavy use of .timeout as well as recovering after .timeout. Due to needing to know if a Monix Task raised an exception due to a timeout, we had to create this ugly workaround

private def isThrowableMonixTimeout(throwable: Throwable): Boolean =
  throwable match {
    // This is the exception that is thrown when you do .timeout on a Task
    case t: TimeoutException if t.getMessage.contains("Task timed-out after") => true
    case _                                                                    => false

This simple PR allows you to specify your own type of TimeoutException

@mdedetrich mdedetrich force-pushed the mdedetrich:specifyExceptionOnTimeout branch from dafe789 to 55b64eb Mar 24, 2019


Avasil approved these changes Mar 24, 2019

Copy link

left a comment

I'm 👍 - we should allow this if we're providing this helper

CI is failing on doc generation:

�[0m[�[0m�[31merror�[0m] �[0m�[0m/home/travis/build/monix/monix/monix-eval/shared/src/main/scala/monix/eval/Task.scala:3209:3: The link target "Task.timeout" is ambiguous. Several members fit the target:�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m(after: scala.concurrent.duration.FiniteDuration,timeoutException: concurrent.TimeoutException): monix.eval.Task[A] in class Task [chosen]�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m(after: scala.concurrent.duration.FiniteDuration): monix.eval.Task[A] in class Task�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0mQuick crash course on using Scaladoc links�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m==========================================�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0mDisambiguating terms and types: Prefix terms with '$' and types with '!' in case both names are in use:�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m - [[scala.collection.immutable.List!.apply class List's apply method]] and�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m - [[scala.collection.immutable.List$.apply object List's apply method]]�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0mDisambiguating overloaded members: If a term is overloaded, you can indicate the first part of its signature followed by *:�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m - [[[scala.collection.immutable.List$.fill[A](Int)(⇒A):List[A]* Fill with a single parameter]]]�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m - [[[scala.collection.immutable.List$.fill[A](Int,Int)(⇒A):List[List[A]]* Fill with a two parameters]]]�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0mNotes:�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m - you can use any number of matching square brackets to avoid interference with the signature�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m - you can use \\. to escape dots in prefixes (don't forget to use * at the end to match the signature!)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m - you can use \\# to escape hashes, otherwise they will be considered as delimiters, like dots.�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m  /** Run two `Task` actions concurrently, and return the first to�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m  ^�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0mone error found�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m(Scalaunidoc / �[31mdoc�[0m) Scaladoc generation failed�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0mTotal time: 44 s, completed Mar 24, 2019 3:39:58 PM�[0m

@mdedetrich mdedetrich force-pushed the mdedetrich:specifyExceptionOnTimeout branch from 55b64eb to ffd435c Mar 25, 2019

@oleg-py oleg-py self-requested a review Mar 25, 2019

@mdedetrich mdedetrich force-pushed the mdedetrich:specifyExceptionOnTimeout branch from ffd435c to 97ffee8 Mar 25, 2019

@Avasil Avasil merged commit 4a61a51 into monix:master Mar 25, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@mdedetrich mdedetrich deleted the mdedetrich:specifyExceptionOnTimeout branch Mar 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.