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);
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.
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.
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.
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.
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); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With