[flutter_tools] Include more details in structured errors sent to a DAP client (#150698)
The debug adapter converts Flutter's structured errors into a text format to be sent to the debug client and shown in the console. When an error is not the first error since the last reload, it is shown as just a summary (since it may be caused by a prior error). In this mode, the filter was causing some important information (the erroring widget) to be omitted. This tweaks the logic to include child nodes of a `DiagnosticBlock` in this mode. Fixes https://github.com/Dart-Code/Dart-Code/issues/4743 ## Before:  ## After: 
This commit is contained in:
@@ -118,7 +118,11 @@ class FlutterErrorFormatter {
|
||||
final bool allChildrenAreLeaf = node.children.isNotEmpty &&
|
||||
!node.children.any((_ErrorNode child) => child.children.isNotEmpty);
|
||||
if (node.level == _DiagnosticsNodeLevel.summary || allChildrenAreLeaf) {
|
||||
_writeNode(node, recursive: false);
|
||||
// DiagnosticsBlock is a container, so recurse into its children if
|
||||
// there's only a single level. The container may be
|
||||
// "The relevant error-causing widget was" and the child may be
|
||||
// the specific widget details.
|
||||
_writeNode(node, recursive: node.type == _DiagnosticsNodeType.DiagnosticsBlock && allChildrenAreLeaf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,6 +152,10 @@ enum _DiagnosticsNodeStyle {
|
||||
flat,
|
||||
}
|
||||
|
||||
enum _DiagnosticsNodeType {
|
||||
DiagnosticsBlock,
|
||||
}
|
||||
|
||||
class _ErrorData extends _ErrorNode {
|
||||
_ErrorData(super.data);
|
||||
|
||||
@@ -167,6 +175,7 @@ class _ErrorNode {
|
||||
List<_ErrorNode> get properties => asList('properties', _ErrorNode.new);
|
||||
bool get showName => data['showName'] != false;
|
||||
_DiagnosticsNodeStyle? get style => asEnum('style', _DiagnosticsNodeStyle.values);
|
||||
_DiagnosticsNodeType? get type => asEnum('type', _DiagnosticsNodeType.values);
|
||||
|
||||
String? asString(String field) {
|
||||
final Object? value = data[field];
|
||||
|
||||
Reference in New Issue
Block a user