Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dont set value if it is a stack trace
  • Loading branch information
denrase committed May 22, 2023
commit f3bc9f42b2b4f575a0b5db9b188c7b9e9cac1153
5 changes: 4 additions & 1 deletion dart/lib/src/sentry_exception_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'protocol.dart';
import 'sentry_options.dart';
import 'sentry_stack_trace_factory.dart';
import 'throwable_mechanism.dart';
import 'utils/stack_trace_utils.dart';

/// class to convert Dart Error and exception to SentryException
class SentryExceptionFactory {
Expand Down Expand Up @@ -57,11 +58,13 @@ class SentryExceptionFactory {
}
}

final throwableString = throwable.toString();

// if --obfuscate feature is enabled, 'type' won't be human readable.
// https://flutter.dev/docs/deployment/obfuscate#caveat
return SentryException(
type: (throwable.runtimeType).toString(),
value: throwable.toString(),
value: throwableString.isStackTrace() ? null : throwableString,
mechanism: mechanism,
stackTrace: sentryStackTrace,
throwable: throwable,
Expand Down
18 changes: 18 additions & 0 deletions dart/test/sentry_exception_factory_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ void main() {

expect(sentryException.throwable, throwable);
});

test('should not assigns stackTrace string to value', () {
final stackTraceError = StackTraceError();
final sentryException =
fixture.getSut().getSentryException(stackTraceError);
expect(sentryException.value, isNull);
});
}

class CustomError extends Error {}
Expand All @@ -187,6 +194,17 @@ class CustomExceptionStackTraceExtractor
}
}

class StackTraceError extends Error {
@override
String toString() {
return '''
#0 baz (file:///pathto/test.dart:50:3)
<asynchronous suspension>
#1 bar (file:///pathto/test.dart:46:9)
''';
}
}

class Fixture {
final options = SentryOptions(dsn: fakeDsn);

Expand Down