# Handle connection failure error

**URL:** <https://www.ruby-forum.com/t/handle-connection-failure-error/179145>\
**Category:** Ruby\
**Created:** [November 18, 2009, 12:50pm UTC](https://www.ruby-forum.com/t/handle-connection-failure-error/179145 "2009-11-18T12:50:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vetrivel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/dc4da7/32.png) [@vetrivel](https://www.ruby-forum.com/u/vetrivel)\
**Post date:** [November 18, 2009, 12:50pm UTC](https://www.ruby-forum.com/t/handle-connection-failure-error/179145/1 "2009-11-18T12:50:49Z")

</div>

doubt in Postgres module in ruby .

using PGConn i connect with database . Then I executed one query .

def executeSql  
query1= "select \* from user\_info ;

```
     begin
       obj.query( query1 )

     rescue PGError => e

     end

```

end

My problem is that , if there is a query error , i will rescue that  
error and i go ahead . But if there is a connection error , i want to  
exit the process . How do i find out whether it is a connection error  
and query error . Is there any Exception handling for connection error  
in ruyu

Thanks
