Open Hixie opened 10 months ago
False positives can occur when completing with an Error
that's known to have a stackTrace
set, intending to use that as the stack trace (which it will be).
It shouldn't be hard to pass error.stackTrace
explicitly instead.
(The default is actually not a stack trace containing only platform internals. The default is the empty stack trace.)
error_completer_stack_trace
I have no idea what the right name for this is so please don't use this one.
Description
Include a stack trace (possibly StackTrace.current) when completing a Completer with an error.
Details
When you call
Completer.completeError
and don't give a stack trace, Dart defaults to a stack trace that only includes internals of the Dart standard library. This makes debugging such errors very difficult. Callers should instead passStackTrace.current
so thatcompleteError
acts more likethrow
, providing a stack trace that corresponds to where the error occurred.Kind
This makes debugging easier.
Bad Examples
Good Examples
Discussion
This is motivated by difficulties debugging code that used futures extensively but without knowing that stack traces should be included.
See https://github.com/dart-lang/sdk/issues/31412.