Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 730
adam-singer Avatar asked Dec 20 '12 01:12

adam-singer


People also ask

What is StackTrace in Dart?

A StackTrace is intended to convey information to the user about the call sequence that triggered an exception. These objects are created by the runtime, it is not possible to create them programmatically.

What is exception StackTrace?

A trace of the method calls is called a stack trace. The stack trace listing provides a way to follow the call stack to the line number in the method where the exception occurs. The StackTrace property returns the frames of the call stack that originate at the location where the exception was thrown.

How do you throw an exception in darts?

Throwing an ExceptionThe throw keyword is used to explicitly raise an exception. A raised exception should be handled to prevent the program from exiting abruptly.

How do you use a dart try-catch?

Dart try-catch is used to execute a block of code that could throw an exception, and handle the exception without letting the program terminate. If an exception, thrown by any of the code, is not handled via catch block, then the program could terminate because of the exception.


1 Answers

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); } 
like image 74
John Evans Avatar answered Sep 25 '22 02:09

John Evans