Unverified Commit d32ad1f9 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Prevent exceptions in _describeRelevantUserCode from hiding other exceptions. (#89073)

parent 0ee2d05d
...@@ -2937,7 +2937,7 @@ Iterable<DiagnosticsNode> debugTransformDebugCreator(Iterable<DiagnosticsNode> p ...@@ -2937,7 +2937,7 @@ Iterable<DiagnosticsNode> debugTransformDebugCreator(Iterable<DiagnosticsNode> p
if (!foundStackTrace && node is DiagnosticsStackTrace) if (!foundStackTrace && node is DiagnosticsStackTrace)
foundStackTrace = true; foundStackTrace = true;
if (_isDebugCreator(node)) { if (_isDebugCreator(node)) {
yield* _parseDiagnosticsNode(node, errorSummary)!; yield* _parseDiagnosticsNode(node, errorSummary);
} else { } else {
if (foundStackTrace) { if (foundStackTrace) {
pending.add(node); pending.add(node);
...@@ -2952,15 +2952,27 @@ Iterable<DiagnosticsNode> debugTransformDebugCreator(Iterable<DiagnosticsNode> p ...@@ -2952,15 +2952,27 @@ Iterable<DiagnosticsNode> debugTransformDebugCreator(Iterable<DiagnosticsNode> p
/// Transform the input [DiagnosticsNode]. /// Transform the input [DiagnosticsNode].
/// ///
/// Return null if input [DiagnosticsNode] is not applicable. /// Return null if input [DiagnosticsNode] is not applicable.
Iterable<DiagnosticsNode>? _parseDiagnosticsNode( Iterable<DiagnosticsNode> _parseDiagnosticsNode(
DiagnosticsNode node, DiagnosticsNode node,
ErrorSummary? errorSummary, ErrorSummary? errorSummary,
) { ) sync* {
if (!_isDebugCreator(node)) assert(_isDebugCreator(node));
return null; try {
final DebugCreator debugCreator = node.value! as DebugCreator; final DebugCreator debugCreator = node.value! as DebugCreator;
final Element element = debugCreator.element; final Element element = debugCreator.element;
return _describeRelevantUserCode(element, errorSummary); yield* _describeRelevantUserCode(element, errorSummary);
} catch (error, stack) {
scheduleMicrotask(() {
FlutterError.reportError(FlutterErrorDetails(
exception: error,
stack: stack,
library: 'widget inspector',
informationCollector: () sync* {
yield DiagnosticsNode.message('This exception was caught while trying to describe the user-relevant code of another error.');
}
));
});
}
} }
Iterable<DiagnosticsNode> _describeRelevantUserCode( Iterable<DiagnosticsNode> _describeRelevantUserCode(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment