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

Include connection info on errors #3334

Open
gabegorelick opened this issue Oct 28, 2024 · 0 comments
Open

Include connection info on errors #3334

gabegorelick opened this issue Oct 28, 2024 · 0 comments

Comments

@gabegorelick
Copy link
Contributor

I have an app that connects to multiple PG instances. When a pg client/pool encounters an error, the only way to know which database was the culprit is to have a handle to the Client/Pool object. But often times your error handling code does not have a handle to the Client/Pool objects (by its nature, error handling code is often disconnected from the code that threw the error). The only thing error handling has a handle to is the error itself.

An example:

try { 
  await doSomethingWithVariableDb();
} catch (err) {
 // This does not currently work.
  console.error("Error doing something with DB " + err.host);
}

It would be nice if pg included this target host info on errors. Alternatively, pg could include the associated Client and/or Pool object on the error. Although that seems more prone to leaking memory.

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

1 participant