Skip to content

Commit f3bc9f4

Browse files
committed
dont set value if it is a stack trace
1 parent 83906b3 commit f3bc9f4

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

dart/lib/src/sentry_exception_factory.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'protocol.dart';
33
import 'sentry_options.dart';
44
import 'sentry_stack_trace_factory.dart';
55
import 'throwable_mechanism.dart';
6+
import 'utils/stack_trace_utils.dart';
67

78
/// class to convert Dart Error and exception to SentryException
89
class SentryExceptionFactory {
@@ -57,11 +58,13 @@ class SentryExceptionFactory {
5758
}
5859
}
5960

61+
final throwableString = throwable.toString();
62+
6063
// if --obfuscate feature is enabled, 'type' won't be human readable.
6164
// https://flutter.dev/docs/deployment/obfuscate#caveat
6265
return SentryException(
6366
type: (throwable.runtimeType).toString(),
64-
value: throwable.toString(),
67+
value: throwableString.isStackTrace() ? null : throwableString,
6568
mechanism: mechanism,
6669
stackTrace: sentryStackTrace,
6770
throwable: throwable,

dart/test/sentry_exception_factory_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ void main() {
169169

170170
expect(sentryException.throwable, throwable);
171171
});
172+
173+
test('should not assigns stackTrace string to value', () {
174+
final stackTraceError = StackTraceError();
175+
final sentryException =
176+
fixture.getSut().getSentryException(stackTraceError);
177+
expect(sentryException.value, isNull);
178+
});
172179
}
173180

174181
class CustomError extends Error {}
@@ -187,6 +194,17 @@ class CustomExceptionStackTraceExtractor
187194
}
188195
}
189196

197+
class StackTraceError extends Error {
198+
@override
199+
String toString() {
200+
return '''
201+
#0 baz (file:///pathto/test.dart:50:3)
202+
<asynchronous suspension>
203+
#1 bar (file:///pathto/test.dart:46:9)
204+
''';
205+
}
206+
}
207+
190208
class Fixture {
191209
final options = SentryOptions(dsn: fakeDsn);
192210

0 commit comments

Comments
 (0)