I have a chain of methods. In every method I have try/catch block like the following sample:
public void DoCommand() {
try {
GetData();
}
catch(Exception ex) {
// I want to show the following and all inner exceptions
// in correct order here (User-friendly stack trace)
}
}
public void GetData() {
try {
GetLowLevelData();
}
catch(Exception ex) {
throw new Exception("Get Data exception", ex);
}
}
public void GetLowLevelData() {
try {
// do something
}
catch(Exception ex) {
throw new Exception("Get Low Level Data exception", ex);
}
}
What's good approach to collect inner exceptions to log it in DoCommand method?