On Monday, 31 October 2016 at 22:20:59 UTC, Kapps wrote:

Wrap a body of the function to try {} catch {} and it'll work.

Assuming you're sure it'll never throw. To enforce this, use try { } catch { throw new Error("blah"); }. You can still throw errors, just not exceptions (as errors are not meant to be caught).

Not advisable in this case. This is for a function intended to be used as a C callback. There's no guarantee any errors thrown will propagate through the C side back into the D side. I wrote an article about this on gamedev.net [1] a while back. The feedback there is what led me to finally declare all of the callback types in Derelict (like the GLFW key callback above) as nothrow. I've since refined my approach, but, unless things have changes significantly (and I don't believe they have) the general idea still holds.

[1] http://www.gamedev.net/page/resources/_/technical/general-programming/d-exceptions-and-c-callbacks-r3323


Reply via email to