You should wrap this statement into a Try (so you will have a Success/Failure depending on the connection result)