How to get rid of "nothrow" ?

Vinod K Chandran kcvinu82 at gmail.com
Sun May 17 14:35:45 UTC 2020


On Sunday, 17 May 2020 at 14:21:41 UTC, Vinod K Chandran wrote:
> On Sunday, 17 May 2020 at 09:50:00 UTC, Olivier Pisano wrote:
>> On Sunday, 17 May 2020 at 09:27:40 UTC, Vinod K Chandran wrote:
>>> Hi all,
>>> I am trying to create a win32 based gui in dlang. So far so 
>>> good. I can create and display my window on screen. But for 
>>> handling messages, i planned to write something like message 
>>> crackers in c++. But since, my WndProc function is a 
>>> "nothrow" function, i cannot use any function without 
>>> "nothorw" in that WndProc. How to solve this problem ?
>>
>> Hi,
>>
>> You need to catch any exceptions inside of your WndProc so 
>> they don't propagate:
>>
>> LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM 
>> wParam, LPARAM lParam) nothrow
>> {
>>     try
>>     {
>>         // your code logic here may call throwing functions
>>     }
>>     catch (Exception e)
>>     {
>>         // You should log exceptions here
>>     }
>> }
>
> Hi, Thanks a lot. Let me try.

It worked. Thanks :) I have one more question. Which is better, 
to include all the switch cases inside a single try catch or 
write separate try catch for each switch cases ?


More information about the Digitalmars-d-learn mailing list