try catch to connection