Ian van der Linde
Ian van der Linde

Reputation: 79

C# Cassandra Datastax driver - Handling failed connection

Is there any way to catch the connection exception thrown by the datastax cassandra driver for C#? It usually works fine, but the catch block does not execute when the remote host is down (that is, when a NoHostAvailableException is thrown). The debugger only halts and indicates the exception at Connect().

        try
        {
            cluster = Cluster.Builder().AddContactPoint("<ip address>").Build();
            session = (Session)cluster.Connect();
        }
        catch (NoHostAvailableException ex)
        {
            //Never executes
        }
        catch (Exception ex)
        {
            //Never executes
        }

Upvotes: 2

Views: 680

Answers (1)

Ian van der Linde
Ian van der Linde

Reputation: 79

Found the fix, Visual Studio has a checkbox where you can choose whether or not you want to break on a certain exception (regardless of a try/catch), unchecking that solved everything.

Upvotes: 1

Related Questions