How do you get the current stacktrace in Dart for a Completer.CompleteException(exception, stackTrace);

有些话、适合烂在心里 提交于 2020-03-18 03:25:30

问题


If some code returns a future and determines that the future should return "Error" or "Exception" how can a stack trace be passed to Completer.completeException(exception, stackTrace);


回答1:


If I understand correctly: when you catch an exception in dart, you can also catch the stack trace:

try {
  // something
} catch(e, stacktrace) {
  myCompleter.completeException(e, stacktrace);
}



回答2:


If you're not in a catch block, you can use StackTrace.current



来源:https://stackoverflow.com/questions/13963837/how-do-you-get-the-current-stacktrace-in-dart-for-a-completer-completeexception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!