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

StackOverflow https://stackoverflow.com/questions/13963837

  •  11-12-2021
  •  | 
  •  

Question

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);

Was it helpful?

Solution

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);
}

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top