On Sunday, 26 March 2017 at 00:34:03 UTC, Jolly James wrote:
How do you catch an std.socket.SocketOSException?


The following does not work, as the exception occurs anyway and leads to a crash:

import ae.net.asockets;

void main(string[] args)
{
        TcpServer tcp = new TcpServer();

        try
        {
                tcp.listen(2345, "127.0.0.1c");
                // '...c' makes the IP address invalid
        }
        catch (std.socket.SocketOSException e)
        {
                return;
        }
        catch (Exception e)
        {
                return;
        }

        socketManager.loop();
}

Output:
std.socket.SocketOSException@std\socket.d(975): getaddrinfo error: Unknown Host

This part:
catch (std.socket.SocketOSException e)
        {
                return;
        }

Is redundant, because SocketOSException inherits SocketException which inherits Exception.

It should already be caught by catch (Exception e)

You should have a full stacktrace, chances are that it's invoked in your loop()?

Reply via email to