File tree Expand file tree Collapse file tree 2 files changed +8
-12
lines changed
Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -36,13 +36,13 @@ protected internal override void DoEnsureSuccessfulResponse([NotNull] HttpReques
3636 var exception = new GraphQLHttpRequestException ( errorMessage ) ;
3737
3838#if NET5_0_OR_GREATER
39- // Add a full stack trace into the exception to improve Issue grouping,
40- // see https://github.com/getsentry/sentry-dotnet/issues/3582
41- ExceptionDispatchInfo . SetCurrentStackTrace ( exception ) ;
39+ // Add a full stack trace into the exception to improve Issue grouping,
40+ // see https://github.com/getsentry/sentry-dotnet/issues/3582
41+ ExceptionDispatchInfo . Throw ( ExceptionDispatchInfo . SetCurrentStackTrace ( exception ) ) ;
42+ #else
43+ // Where SetCurrentStackTrace is not available, just throw the Exception
44+ throw exception ;
4245#endif
43- // Wrap in a new exception to preserve the stack trace when thrown and caught.
44- // The inner exception will have the full stack trace for better issue grouping.
45- throw new GraphQLHttpRequestException ( errorMessage , exception ) ;
4646 }
4747 }
4848 // No GraphQL errors, but we still might have an HTTP error status
Original file line number Diff line number Diff line change @@ -211,9 +211,6 @@ public void HandleResponse_Error_CaptureRequestAndResponse()
211211 // Ensure it's a GraphQL exception (not HTTP fallback)
212212 @event . Exception . Should ( ) . BeOfType < GraphQLHttpRequestException > ( ) ;
213213 @event . Exception ! . Message . Should ( ) . Be ( DefaultErrorMessage ) ;
214- @event . Exception ! . InnerException . Should ( ) . NotBeNull ( "inner exception should have the stack trace" ) ;
215- @event . Exception ! . InnerException . Should ( ) . BeOfType < GraphQLHttpRequestException > ( ) ;
216- @event . Exception ! . InnerException ! . Message . Should ( ) . Be ( DefaultErrorMessage ) ;
217214
218215 // Ensure the mechanism is set
219216 @event . Exception ? . Data [ Mechanism . MechanismKey ] . Should ( ) . Be ( SentryGraphQLHttpFailedRequestHandler . MechanismType ) ;
@@ -330,10 +327,9 @@ public void HandleResponse_GraphQLError_ExceptionStackTraceHasCallerContext()
330327 {
331328 @event . Should ( ) . NotBeNull ( ) ;
332329 @event . Exception . Should ( ) . NotBeNull ( ) ;
333- @event . Exception ! . InnerException . Should ( ) . NotBeNull ( ) ;
334330
335- // Inner exception 's stack trace should include this test method name, proving we captured caller context on .NET 5+
336- @event . Exception ! . InnerException ! . StackTrace . Should ( ) . Contain ( nameof ( HandleResponse_GraphQLError_ExceptionStackTraceHasCallerContext ) ) ;
331+ // Exception 's stack trace should include this test method name, proving we captured caller context on .NET 5+
332+ @event . Exception ! . StackTrace . Should ( ) . Contain ( nameof ( HandleResponse_GraphQLError_ExceptionStackTraceHasCallerContext ) ) ;
337333 }
338334 }
339335#endif
You can’t perform that action at this time.
0 commit comments