Safe save to DB even it disconnect

I have GenServer that should try to save data into DB each 3 mins:
Process.send_after(self(), :save, 1000*@idle_time_for_save)
Then by handling :save DB is shutdown by some reason i need to catch this situation in some way and schedule saving again.
But it seems like there is no way to catch:
[error] Postgrex.Protocol (#PID<0.486.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.8930.7> timed out because it checked out the connection for longer than 10000ms

What did you try? AFAIK rescue should work here.

Why not just check the connection back into the pool? And checkout again when you need it again? Or are you really performing a database action which takes longer than 10 seconds?

If database disappear accidentally then disconnect happen.

Can You provide an example please?

But with another error which youd handle differently…

Nope, since I do not know how you actually pilled the connection out of the pool. Please show some more code.