@@ -1162,13 +1162,17 @@ class ChromeProxyService implements VmServiceInterface {
1162
1162
);
1163
1163
_logger.info ('\$ dartHotReloadDwds request complete.' );
1164
1164
} catch (e) {
1165
- // TODO(srujzs): We should bubble up the error, but `ReloadReport` needs
1166
- // more fields to capture that info.
1167
1165
_logger.info ('Hot reload failed: $e ' );
1168
- return ReloadReport (success: false );
1166
+ final report = _ReloadReportWithMetadata (success: false );
1167
+ report.json = {
1168
+ 'notices' : [
1169
+ {'message' : e.toString ()},
1170
+ ],
1171
+ };
1172
+ return report;
1169
1173
}
1170
1174
_logger.info ('Successful hot reload' );
1171
- return ReloadReport (success: true );
1175
+ return _ReloadReportWithMetadata (success: true );
1172
1176
}
1173
1177
1174
1178
@override
@@ -1757,6 +1761,28 @@ class ChromeProxyService implements VmServiceInterface {
1757
1761
}
1758
1762
}
1759
1763
1764
+ // The default `ReloadReport`'s `toJson` only emits the type and success of the
1765
+ // operation. Override it to expose additional possible metadata in the `json`.
1766
+ // This then gets called in the VM service code that handles request and
1767
+ // responses.
1768
+ class _ReloadReportWithMetadata extends ReloadReport {
1769
+ _ReloadReportWithMetadata ({super .success});
1770
+
1771
+ @override
1772
+ Map <String , dynamic > toJson () {
1773
+ final jsonified = < String , Object ? > {
1774
+ 'type' : type,
1775
+ 'success' : success ?? false ,
1776
+ };
1777
+ // Include any other metadata we may have included in `json`, potentially
1778
+ // even overriding the above defaults.
1779
+ for (final jsonKey in super .json? .keys ?? < String > []) {
1780
+ jsonified[jsonKey] = super .json! [jsonKey];
1781
+ }
1782
+ return jsonified;
1783
+ }
1784
+ }
1785
+
1760
1786
/// The `type` s of [ConsoleAPIEvent] s that are treated as `stderr` logs.
1761
1787
const _stderrTypes = ['error' ];
1762
1788
0 commit comments