The problem is that it is not very specific. I am writing a fairly large package and using other free packages for numerics and graphics and there can be many different kinds of errors or exceptions occuring, the simplest may be division by zero or that a matrix inversion goes wrong because the matrix is singluar or more sophisticated that during the calculation of the equilibrium a new phase wants to be stable so I have to redesign the equations to find the minimium. The errors may occur deep down in the code, sometimes in parts of the code I have not written myself, but the upper levels of the code can usually find a way to bypass the error/exception and continue the calculation, the errors are usually not fatal.
It works OK in sequential execution with a single error code but when parallellizing each thread must have its own error code so that the exception in one thread does not distrurb the other. I think threadprivate would be a reasonable solution, what worries me is that I have learned this threadprivate data makes the code significantly slower. But maybe a single variable is not so problematic? There are frequent tests of this variable in to code in order to detect errors/exceptions as early as possible.