From c@@rdi@g@bor @ending from gm@il@com  Sat Jul 28 19:40:30 2018
From: c@@rdi@g@bor @ending from gm@il@com (=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=)
Date: Sat, 28 Jul 2018 18:40:30 +0100
Subject: [Rd] re-throwing an interrupt condition
In-Reply-To: <alpine.DEB.2.20.1807281230170.3311@luke-Latitude-7480>
References: <CABtg=Knd2fmhRZcokroQmV8yv_p_X3OKRWtfwiRrhb-5YJMfpg@mail.gmail.com>
 <alpine.DEB.2.20.1807281230170.3311@luke-Latitude-7480>
Message-ID: <CABtg=K=VSpVTN1AOGHi7rJYgrVHd7Lh0gGZ+vv7D-4h8CBVcBA@mail.gmail.com>

Great! invokeRestart("abort") is a life saver again, the second time this week!

Thanks much!

Gabor

On Sat, Jul 28, 2018 at 6:37 PM <luke-tierney at uiowa.edu> wrote:
>
> The internal code does more or less
>
>      signalCondition(e)     ## allows for (another) handler
>      cat("\n")              ## cleans up console
>      invokeRestart("abort") ## jump to 'abort' restart if not handled
>
> [for back compatibility it also runs the error option code if that is
> set, but that may go away eventually].
>
> A version of your example:
>
> > {
> +     tryCatch(Sys.sleep(100),
> +              interrupt = function(e) {
> +                  e$message <- "interrupted"
> +                  signalCondition(e)
> +                  cat("\n")
> +                  invokeRestart("abort")
> +     })
> +     cat("next step\n")
> + }
> ^C
> >
>
> Best,
>
> luke
>
> On Sat, 28 Jul 2018, G?bor Cs?rdi wrote:
>
> > Anyone knows a way to re-throw a caught interrupt condition, so that
> > it behaves just like the original one? I.e. no error message is
> > printed, but the execution is stopped of course. With just calling
> > stop in the error handler, it prints the error message, or, if there
> > is no error message (like in the original interrupt condition),
> > another error happens.
> >
> > tryCatch(Sys.sleep(100), interrupt = function(e) {  e$message <-
> > "interrupted"; stop(e) } )
> > <press CTRL + C / ESC here>
> > #> Error: interrupted
> >
> > tryCatch(Sys.sleep(100), interrupt = function(e) stop(e))
> > <press CTRL + C / ESC here>
> > #> Error in stop(e) : bad error message
> >
> > Thanks,
> > Gabor
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
> --
> Luke Tierney
> Ralph E. Wareham Professor of Mathematical Sciences
> University of Iowa                  Phone:             319-335-3386
> Department of Statistics and        Fax:               319-335-3017
>     Actuarial Science
> 241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
> Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] re-throwing an interrupt condition
=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=