On Monday, 31 October 2016 at 17:04:28 UTC, Temtaime wrote:
On Monday, 31 October 2016 at 16:55:51 UTC, WhatMeWorry wrote:
Is there a way to turn off nothrow or work around it? Because
to me it looks like nothrow prevents me from doing anything
useful.
extern(C) void onKeyEvent(GLFWwindow* window, int key, int
scancode, int action, int modifier) nothrow
{
if(queue.roomInQueue())
{
auto event = new Event;
event.type = EventType.keyboard;
event.keyboard.key = cast(Key) key;
// etc.
}
Error: function 'event_handler.CircularQueue.roomInQueue' is
not nothrow
Error: function 'event_handler.onKeyEvent' is nothrow yet may
throw
The compiler wouldn't let me just remove "nothrow" from the
function. I tried a kludge where I had this function just pass
all its parameters to another throwable function, but this
caused errors as well.
So I'm stuck. Anyone know how to proceed.
Thanks.
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).