From c@@rdi@g@bor @ending from gm@il@com  Sat Jul 28 19:51:11 2018
From: c@@rdi@g@bor @ending from gm@il@com (=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=)
Date: Sat, 28 Jul 2018 18:51:11 +0100
Subject: [Rd] re-throwing an interrupt condition
In-Reply-To: <alpine.DEB.2.20.1807281238100.3311@luke-Latitude-7480>
References: <CABtg=Knd2fmhRZcokroQmV8yv_p_X3OKRWtfwiRrhb-5YJMfpg@mail.gmail.com>
 <CALEXWq0aNQR7FG7pSiDbcMuUTG6c1K2sF-GK-GeGaeVOv=Y=Kw@mail.gmail.com>
 <CABtg=KkzVQEH0ryq5YrTg9mr=pQ71EGQgL32afJ+qY0nvFqZMQ@mail.gmail.com>
 <alpine.DEB.2.20.1807281238100.3311@luke-Latitude-7480>
Message-ID: <CABtg=K=XxCBP5tsLviREHqbO47bdq-tm=jmB3ogHfd+=p8ZOxg@mail.gmail.com>

Good points. In my case I also want to add an extra class to the
condition, before re-throwing it.
Sorry, this was not clear in my first email, I actually just realized it now.

Gabor
On Sat, Jul 28, 2018 at 6:43 PM <luke-tierney at uiowa.edu> wrote:
>
> On Sat, 28 Jul 2018, G?bor Cs?rdi wrote:
>
> > I don't want to return a value, I want to interrupt the computation,
> > that's why I need to re-throw .
> > But before getting back to the user I want to run some cleanup code.
>
> If it is just cleanup you want then a finally clause or on.exit should
> do, and will cover all form of non-local transfer of control.
>
> Best,
>
> luke
>
> >
> > G.
> > On Sat, Jul 28, 2018 at 5:59 PM I?aki ?car <i.ucar86 at gmail.com> wrote:
> >>
> >> El s?b., 28 jul. 2018 a las 18:30, G?bor Cs?rdi
> >> (<csardi.gabor at gmail.com>) escribi?:
> >>>
> >>> 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
> >>
> >> Sorry, I probably misunderstood your intention, but... simply by not
> >> calling stop at all? This is what I see:
> >>
> >>> tryCatch(Sys.sleep(100), interrupt = function(e) do_something <<- 1)
> >> <press CTRL + C / ESC here>
> >> ^C>
> >>> do_something
> >> [1] 1
> >>
> >> I?aki
> >
> > ______________________________________________
> > 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=?=