I need to implement an exception handling system for a very large C++ code. I need to implement a standard which meets the following specifications:
- Print out the call trace when an exception is thrown
- Allow the developer to specify optional additional information about the state of a function when the exception is called. (e.g. the value of a counter during an iteration)
- Easy to implement (since I will not be able to do it myself)
- Uninvasive
- Portable
It seems to me as though putting try/catch blocks in every single function is the only possible solution, but this seems generally fround upon and considered to be bad practice. It is also clumsy and difficult to maintain/implement consistently.
I have also looked into libraries like stacktrace, but they seem limited on portability and I would have to sacrifice the ability for optional additional state information.
Edit: what is the best way to do this?