Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
88e39d2
sample on how to recursiveley extract errors
denrase Dec 19, 2022
ba00651
Merge branch 'v7.0.0' into feat/exception-extractor
denrase Jan 10, 2023
81394d1
introduce exception cause with exception and stacktrace
denrase Jan 10, 2023
620e917
move extractors to options
denrase Jan 10, 2023
1c7d835
extract exceptions and attach as sentry exceptions to sentry event
denrase Jan 10, 2023
2584bad
Merge branch 'v7.0.0' into feat/exception-extractor
denrase Jan 16, 2023
e8384ca
make internal field private
denrase Jan 16, 2023
b4fb217
make var final
denrase Jan 16, 2023
077aff4
make var final
denrase Jan 16, 2023
a1acbf3
add tests covering stacktrace attachments
denrase Jan 16, 2023
fcd1a38
check if correct stacktrace was captured
denrase Jan 16, 2023
34e9e8a
break circularity
denrase Jan 16, 2023
84f1104
add changelog entry
denrase Jan 16, 2023
0c15cd2
Merge branch 'v7.0.0' into feat/exception-extractor
denrase Jan 17, 2023
413ddd0
expose type in extractor
denrase Jan 17, 2023
4af4d07
export classes
denrase Jan 17, 2023
5159821
move recursivce extractor to exception factory
denrase Jan 17, 2023
983bdf3
format
denrase Jan 17, 2023
bde4df0
remove todo
denrase Jan 17, 2023
4bd8ad4
add throwable to sentry exception
denrase Jan 17, 2023
406e493
Merge branch 'v7.0.0' into feat/exception-extractor
denrase Jan 17, 2023
61900d4
apply new approach in dio event processor
denrase Jan 17, 2023
5d78242
update changelog
denrase Jan 17, 2023
b2abac7
dont remove stacktrace from DioError
denrase Jan 17, 2023
2e65a9e
preserve throwable mechanism
denrase Jan 17, 2023
4f37d19
search for first in list
denrase Jan 23, 2023
72cfb5b
search for dioexception in list
denrase Jan 23, 2023
db64952
Merge branch 'v7.0.0' into feat/exception-extractor
denrase Jan 23, 2023
dcbc09f
format changelog
denrase Jan 23, 2023
4938f3a
Merge branch 'v7.0.0' into feat/exception-extractor
denrase Jan 23, 2023
cce32de
format changelog
denrase Jan 23, 2023
22196e6
format
denrase Jan 23, 2023
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
move extractors to options
  • Loading branch information
denrase committed Jan 10, 2023
commit 620e917d5b2a5383c4fa581b758c960842fee568
8 changes: 5 additions & 3 deletions dart/lib/src/exception_cause_extractor.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '../sentry.dart';
import 'exception_cause.dart';

class ExceptionCauseExtractor<T> {
Expand All @@ -7,9 +8,9 @@ class ExceptionCauseExtractor<T> {
}

class RecursiveExceptionCauseExtractor {
RecursiveExceptionCauseExtractor(this.causeExtractorsByType);
RecursiveExceptionCauseExtractor(this.options);

final Map<Type, ExceptionCauseExtractor> causeExtractorsByType;
SentryOptions options;

List<ExceptionCause> flatten(exception, stackTrace) {
var allExceptionCauses = <ExceptionCause>[];
Expand All @@ -21,7 +22,8 @@ class RecursiveExceptionCauseExtractor {
while (currentException != null && currentExceptionCause != null) {
allExceptionCauses.add(currentExceptionCause);

final extractor = causeExtractorsByType[currentException.runtimeType];
final extractor =
options.causeExtractorsByType[currentException.runtimeType];
currentExceptionCause = extractor?.cause(currentException);
currentException = currentExceptionCause?.exception;
}
Expand Down
14 changes: 14 additions & 0 deletions dart/lib/src/sentry_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:http/http.dart';
import '../sentry.dart';
import 'client_reports/client_report_recorder.dart';
import 'client_reports/noop_client_report_recorder.dart';
import 'exception_cause_extractor.dart';
import 'sentry_exception_factory.dart';
import 'sentry_stack_trace_factory.dart';
import 'diagnostic_logger.dart';
Expand Down Expand Up @@ -327,6 +328,19 @@ class SentryOptions {
/// The default is 3 seconds.
Duration? idleTimeout = Duration(seconds: 3);

final _causeExtractorsByType = <Type, ExceptionCauseExtractor>{};

Map<Type, ExceptionCauseExtractor> get causeExtractorsByType =>
_causeExtractorsByType;

void addTypedExceptionCauseExtractor(
Type type, ExceptionCauseExtractor extractor) {
_causeExtractorsByType[type] = extractor;
}

@internal
late final extractor = RecursiveExceptionCauseExtractor(this);

SentryOptions({this.dsn, PlatformChecker? checker}) {
if (checker != null) {
platformChecker = checker;
Expand Down
33 changes: 29 additions & 4 deletions dart/test/exception_cause_extractor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,48 @@ import 'package:sentry/src/exception_cause.dart';
import 'package:sentry/src/exception_cause_extractor.dart';
import 'package:test/test.dart';

import 'package:sentry/sentry.dart';

import 'mocks.dart';

void main() {
late Fixture fixture;

setUp(() {
fixture = Fixture();
});

test('flatten', () {
final errorC = ExceptionC();
final errorB = ExceptionB(errorC);
final errorA = ExceptionA(errorB);

final sut = RecursiveExceptionCauseExtractor({
ExceptionA: ExceptionACauseExtractor(),
ExceptionB: ExceptionBCauseExtractor()
});
fixture.options.addTypedExceptionCauseExtractor(
ExceptionA,
ExceptionACauseExtractor(),
);

fixture.options.addTypedExceptionCauseExtractor(
ExceptionB,
ExceptionBCauseExtractor(),
);

final sut = fixture.getSut();

final flattened = sut.flatten(errorA, null);
final actual = flattened.map((exceptionCause) => exceptionCause.exception);
expect(actual, [errorA, errorB, errorC]);
});
}

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

RecursiveExceptionCauseExtractor getSut() {
return RecursiveExceptionCauseExtractor(options);
}
}

class ExceptionA {
ExceptionA(this.other);
final ExceptionB? other;
Expand Down