catching Throwable is wrong. But is it wrong if I used it in separate thread to prevent thread dying like:

static void run()
{
        while(true)
        {
                try
                {
                        /// do work
                        ...

                        // interacting with parent
                        auto msg = receiveTimeout(dur!"msecs"(1),
                                (string command)
                                {
                                        /// process command from parent
                                        if(some_condition_is_true)
                                                break; // finish
                                                       // execution
                                }
                        );
                }
                catch(Throwable t)
                {
                        /// some diagnostic message
                }
        }
}

...

auto child = spawn(&run);

...

?

Reply via email to