DEV Community

Discussion on: TIL: Using Different Database Connection with ActiveRecord Transactions

rhymes profile image

it is required to save the error response to the db, but maybe it could be done outside of communicator. I'll have to think about this some more.

See it like this. The service object should be responsible for one thing only. In the future you might want to do N different things with the response. You might want to save it on the DB, you might want to log it on an external service, you might want to extract info from it. Separating the two steps should simplify the logic. In an extreme case you might even save the error later and asynchronously ;)

Thread Thread
amrrbakry profile image
Amr El-Bakry Author • Edited

yeah, maybe another service could handle dealing with the response and whatever we want to do with it :D