I guess there are many ways forward if you want to do this. One of the hardest problems is the concept of "most important bits". The most important bits are the exact bits needed to re-create your program. Think of it as a save state in an emulator, or serializing changes made to a read-only database, all in an effort to reduce the state necessary to go back later.
No matter what solutions you offer when catching errors, the problem of the most important bits is a hard one, and one that you yourself need to implement in every program. Quite frankly, almost nobody add these features. We were considering paying the Botan creator to add serialization to his TLS library, and he found that it would be too much work, so he ended up declining. I had to add it to s2n, but they were never interested in it, so I maintained it myself until eventually I discarded it. All in the effort to recreate a full networking stack after hotswapping an entire OS in milliseconds. Quite a fun project. Nevertheless, I don't think it will ever be easy.
No matter what solutions you offer when catching errors, the problem of the most important bits is a hard one, and one that you yourself need to implement in every program. Quite frankly, almost nobody add these features. We were considering paying the Botan creator to add serialization to his TLS library, and he found that it would be too much work, so he ended up declining. I had to add it to s2n, but they were never interested in it, so I maintained it myself until eventually I discarded it. All in the effort to recreate a full networking stack after hotswapping an entire OS in milliseconds. Quite a fun project. Nevertheless, I don't think it will ever be easy.