elixir-ecto / db_connection

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

Alter functions to pass error tuple instead of raising errors #264

Closed jbavari closed 1 year ago

jbavari commented 2 years ago

As per #260 , we wanted a way to prevent raising errors and instead return error tuples.

I may be missing something - seeking some additional guidance to figure out what's needed to make it return error tuple instead of raising.

Would love any feedback or suggestions the team would have. From where I sit, I would even think just overriding the userspace Repo.insert call to try/catch may be an easier fit over all. Happy to explore with the team!

josevalim commented 2 years ago

Using the application environment is a no-no but you can pass this as an option. However, as much as it pains me to say this, this will definitely have further implications in transactions and similar, so the best is to most likely to rescue the exception. :(