此代码:如何重新抛出异常并保留堆栈跟踪?
try {
try {
throw 1;
} catch (e, s) {
print("$e $s");
throw e;
}
} catch (e2, s2) {
print("$e2 $s2");
}
打印:
1 #0 main (file:///.../test.dart:34:7)
1 #0 main (file:///.../test.dart:37:7)
所以原来的堆栈跟踪完全丧失。有没有什么方法可以保留堆栈跟踪重新抛出?
会发生什么? – Ladicek
@Ladicek,Dart中是否有'rethrow'关键字?我无法在网上找到它的证据,而我的Dart安装不理解它。 –
@DarshanComputing请参阅规范的第12.8.1章。 – Ladicek