db0 icon indicating copy to clipboard operation
db0 copied to clipboard

refactor(postgres): throw better error on connection fail

Open ToBinio opened this issue 11 months ago โ€ข 0 comments

โ“ Type of change

  • [ ] ๐Ÿ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • [ ] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [X] ๐Ÿ‘Œ Enhancement (improving an existing functionality like performance)
  • [ ] โœจ New feature (a non-breaking change that adds functionality)
  • [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

currently, if no connection can be established the error simply says

ECONNREFUSED: Failed to connect

When using db0 in e.g. Nitro this does not tell you a lot. With this PR the message looks like this:

ECONNREFUSED: Failed to connect - could not connect to Postgres DB at ""

this clearly tells you that something is wrong with your postgres db

๐Ÿ“ Checklist

  • [ ] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

Note

currently, the connector in the postgresql.ts is called sqliteConnector. Which I don't think it should. If you agree let me know and I will quickly create a PR for it.

ToBinio avatar Mar 29 '24 08:03 ToBinio