@@ -1162,13 +1162,17 @@ class ChromeProxyService implements VmServiceInterface {
11621162 );
11631163 _logger.info ('\$ dartHotReloadDwds request complete.' );
11641164 } catch (e) {
1165- // TODO(srujzs): We should bubble up the error, but `ReloadReport` needs
1166- // more fields to capture that info.
11671165 _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;
11691173 }
11701174 _logger.info ('Successful hot reload' );
1171- return ReloadReport (success: true );
1175+ return _ReloadReportWithMetadata (success: true );
11721176 }
11731177
11741178 @override
@@ -1757,6 +1761,28 @@ class ChromeProxyService implements VmServiceInterface {
17571761 }
17581762}
17591763
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+
17601786/// The `type` s of [ConsoleAPIEvent] s that are treated as `stderr` logs.
17611787const _stderrTypes = ['error' ];
17621788
0 commit comments