我有一系列方法。在每个方法中,我都尝试/捕获块,如下例所示:
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);
}
}
收集内部异常以在DoCommand方法中记录它的好方法是什么?