[racket] Setting exception handler for GUI message loop
Thank you for help.
On Fri, Aug 22, 2014 at 7:21 PM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
>
> Think along this minimal example:
>
> #lang racket/gui
>
> (define frame (new frame% [label "x"][width 200][height 200]))
>
> (define button
> (new button%
> [label "hello world"]
> [parent frame]
> [callback
> (lambda (b e)
> (/ 1 0))]))
>
> (queue-callback
> (lambda ()
> (uncaught-exception-handler
> (lambda (xn)
> (displayln `(qb ,(exn-message xn)))))))
>
> (send frame show #t)
>
>
>
>
> On Aug 22, 2014, at 11:18 AM, Dmitry Cherkassov <dcherkassov at gmail.com> wrote:
>
>> WIll that install my exception handler only for calls under
>> `(parameterize uncaught-exception-hamdler () ... )` or for all the
>> stuff in GUI thread?
>>
>> On Fri, Aug 22, 2014 at 6:57 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>>> If you're not already in the handler thread (which is the same as the
>>> initial thread for the initial eventspace), then you can use
>>> `queue-callback` to run a thunk in the current eventspace's handler
>>> thread.
>>>
>>> At Fri, 22 Aug 2014 18:51:26 +0400, Dmitry Cherkassov wrote:
>>>>> Another possibility is to set the `uncaught-exception-handler` parameter (in
>>>> the eventspace's main thread).
>>>> set as dynamic parameter via `parameterize'?
>>>>
>>>> how do i get to GUI thread to accomplish that?
>>>>
>>>>
>>>>
>>>> On Fri, Aug 22, 2014 at 6:37 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>>>>> Another possibility is to set the `uncaught-exception-handler`
>>>>> parameter (in the eventspace's main thread).
>>>>>
>>>>> At Fri, 22 Aug 2014 10:37:35 -0400, Matthias Felleisen wrote:
>>>>>>
>>>>>> Your question is somewhat generic. You will need to equip each callback/event
>>>>>> handler with an exn handler that puts the exception into a channel so that
>>>>>> another thread can pick it up. -- Matthias
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Aug 22, 2014, at 6:58 AM, Dmitry Cherkassov <dcherkassov at gmail.com> wrote:
>>>>>>
>>>>>>> Hi!
>>>>>>>
>>>>>>> Is it possible to set an exception handler to GUI message loop, so
>>>>>>> that any exception thrown in GUI thread can be handled?
>>>>>>>
>>>>>>> --
>>>>>>> With best regards,
>>>>>>> Dmitry
>>>>>>> ____________________
>>>>>>> Racket Users list:
>>>>>>> http://lists.racket-lang.org/users
>>>>>>
>>>>>>
>>>>>> ____________________
>>>>>> Racket Users list:
>>>>>> http://lists.racket-lang.org/users
>>>>
>>>>
>>>>
>>>> --
>>>> With best regards,
>>>> Dmitry
>>
>>
>>
>> --
>> With best regards,
>> Dmitry
>
--
With best regards,
Dmitry