elixir-ecto / db_connection

Database connection behaviour
http://hexdocs.pm/db_connection/DBConnection.html
306 stars 113 forks source link

DBConnection.prepare raises DBConnection.ConnectionError #77

Closed hzamani closed 7 years ago

hzamani commented 7 years ago

Are DBConnection.prepare/3 and DBConnection.execute/4 expected to raise errors? If this is the case then why there are prepare!/3 and execute!/4 functions there?

fishcakez commented 7 years ago

The bang and non bang variants are for exceptions returned by a connection, rather than by pool.

In Postgrex's case it will raise some of the connection exceptions on non bang. Only errors from postgres are not raised when no bang, e.g. constraint error. This occurs because postgres errors likely fit into business logic but others do not, so likely do not want to handle in same place.

On 12 Feb 2017 6:50 am, "Hassan Zamani" notifications@github.com wrote:

Are DBConnection.prepare/3 and DBConnection.execute/4 expected to raise errors? If this is the case then why there are prepare!/3 and execute!/4 functions there?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/elixir-ecto/db_connection/issues/77, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6JTU3u3wJMtJZquHFPcPyCiRIbWr64ks5rbqu2gaJpZM4L-aVO .

fishcakez commented 7 years ago

The pool exceptions are now returned on master: https://github.com/elixir-ecto/db_connection/commit/53271f7d2636bafca3966bbee44d0ecf70d10064.