My technical manager insists on this exception mechanism:
try
{
DoSth();
}
catch (OurException)
{
throw;
}
catch (Exception ex)
{
Util.Log(ex.Message, "1242"); // 1242 is unique to this catch block
throw new OurException(ex);
}
1242 here is the identifier of a catch method that handles an exception other than OurException. Each catch block in the project must have a unique identifier, so that we can know where the exception occurred by looking at the logs.
For each method, we must catch OurException and throw it. If another type of exception occurs, we must register and mask it using the OurException method before resetting it.
Is this a smart approach? If there are any, what are the best alternatives?
Edit: I was told that stack trace does not produce meaningful results in release mode. Do you assume that catching and throwing general exceptions is okay?
Edit2: . , , , . .