Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get original PG error code? #17

Closed
regorov opened this issue Nov 26, 2013 · 1 comment
Closed

How can I get original PG error code? #17

regorov opened this issue Nov 26, 2013 · 1 comment

Comments

@regorov
Copy link

regorov commented Nov 26, 2013

Hi !

As instance

  • I established connection.
  • In few hours server with PG goes down
  • I'd like be switch to another PG instance (slave)

How can I get 'connection lost' moment?

BTW, there is a list with original error codes http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html what are not included into gorm.errors

Thank you in advance!

@jinzhu
Copy link
Member

jinzhu commented Nov 27, 2013

The error should be returned by the postgres driver, then gorm is possible to know which error happened.

I tried to stop postgres when running a service, got error "dial tcp 127.0.0.1:5432: connection refused" in my local.

Anyway I don't think handle postgres exception in gorm is not a good idea, maybe better use a load balancer and mointior to do handle those issues. check it out. http://www.postgresql.org/docs/9.3/static/high-availability.html

@jinzhu jinzhu closed this as completed Nov 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants