From: Erik Hollensbe Date: 2008-11-19T19:29:23+09:00 Subject: Re: "rescue Postgres::PGError" not working Mandeep Baruah wrote: > I am trying to rescue exceptions from a PostgreSQL query (see bellow > code) > --------------------------------------------------- > begin > res = @pgconn.exec(querystring) # some query > rescue Postgres::PGError => e > puts "Error code: #{e.err}" > puts "Error message: #{e.errstr}" > end > --------------------------------------------------- > (I know that the query I am tring to execute will give an exception) > But when I try to execute, it give me an error saying: > "dependencies.rb:493:in `const_missing': uninitialized constant > UpdateTestlinkDB::Postgres (NameError)" > > Is there a different way to handle exception or, am I missing something? I'm fairly certain (unless it's changed, then I have some code to push) that the class is PGError, not Postgres::PGError. This would explain your error, as ruby will first search the current namespace, then the global namespace, looking for your constant (Postgres in this case), and will report it missing. -Erik -- Posted via http://www.ruby-forum.com/.