newbie problem with nothrow
Temtaime via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 31 10:04:28 PDT 2016
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.
More information about the Digitalmars-d-learn
mailing list