Skip to content

Commit 38f6c82

Browse files
jakemac53Commit Queue
authored and
Commit Queue
committed
record and print the original stack trace for argument errors
Change-Id: I5d3e5421bc06547463c060ecf70cecd773c1a753 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341701 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Jake Macdonald <[email protected]> Auto-Submit: Jake Macdonald <[email protected]>
1 parent 877dbd7 commit 38f6c82

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkg/_fe_analyzer_shared/lib/src/macros/executor/executor_base.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,12 @@ abstract class ExternalMacroExecutorBase extends MacroExecutor {
225225
requestId: requestId,
226226
responseType: resultType,
227227
serializationZoneId: zoneId);
228-
} on ArgumentError catch (error) {
228+
} on ArgumentError catch (error, stackTrace) {
229229
// TODO: Something better here.
230230
if (requestId == null) rethrow;
231231
response = new SerializableResponse(
232232
error: '$error',
233+
stackTrace: '$stackTrace',
233234
requestId: requestId,
234235
responseType: MessageType.argumentError,
235236
serializationZoneId: zoneId);

pkg/_fe_analyzer_shared/lib/src/macros/executor/protocol.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class SerializableResponse implements Response, Serializable {
101101
case MessageType.argumentError:
102102
deserializer.moveNext();
103103
error = deserializer.expectString();
104+
deserializer.moveNext();
105+
stackTrace = deserializer.expectNullableString();
104106
break;
105107
case MessageType.macroInstanceIdentifier:
106108
response = new MacroInstanceIdentifierImpl.deserialize(deserializer);
@@ -150,6 +152,7 @@ class SerializableResponse implements Response, Serializable {
150152
break;
151153
case MessageType.argumentError:
152154
serializer.addString(error!.toString());
155+
serializer.addNullableString(stackTrace?.toString());
153156
break;
154157
default:
155158
response.serializeNullable(serializer);
@@ -792,7 +795,8 @@ T _handleResponse<T>(Response response) {
792795
if (response.responseType == MessageType.error) {
793796
throw new RemoteException(response.error!.toString(), response.stackTrace);
794797
} else if (response.responseType == MessageType.argumentError) {
795-
throw new ArgumentError(response.error!.toString());
798+
throw new ArgumentError('${response.error!.toString()}'
799+
'${response.stackTrace == null ? '' : '\n\n${response.stackTrace}'}');
796800
}
797801

798802
return response.response as T;

0 commit comments

Comments
 (0)