Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6a5d2c3
hub interface & instanciation
rxlabz Oct 15, 2020
4f01775
- hub capture event
rxlabz Oct 15, 2020
ea5c55f
- hub capture exception
rxlabz Oct 15, 2020
bd09da0
hub captureMessage
rxlabz Oct 15, 2020
c5317a4
fix some tests
rxlabz Oct 15, 2020
6a8910e
fix more tests
rxlabz Oct 15, 2020
f5d3dd0
changelog
rxlabz Oct 15, 2020
f102ac3
fix all tests
rxlabz Oct 15, 2020
055b9b0
feedbacks
rxlabz Oct 15, 2020
370d2d5
fix test : revert to ArgumentError.notNull('options')
rxlabz Oct 15, 2020
974d1f6
remove required hub methods
rxlabz Oct 15, 2020
c8c1df0
implement `Hub.close()`
rxlabz Oct 16, 2020
6c6c649
feedbacks : remove the IHub interface + minors
rxlabz Oct 16, 2020
a924040
Hub.configureScope
rxlabz Oct 16, 2020
823c91c
Hub.clone and Scope.clone
rxlabz Oct 16, 2020
b04d67c
remove the non required scope methods
rxlabz Oct 16, 2020
37cf83c
replace the ListQueue _stack by a DoubleLinkedQueue
rxlabz Oct 16, 2020
b9f9f9e
rename `response` to `sentryId`
rxlabz Oct 16, 2020
5067a36
serialize the potential error stackTrace
rxlabz Oct 16, 2020
54729ba
Revert the DoubleLinkedQueue to a resourceless ListQueue
rxlabz Oct 16, 2020
729d6bc
fix a json serialization test
rxlabz Oct 16, 2020
4ea1537
add a const SentryId.emptyId
rxlabz Oct 16, 2020
5932534
don't assign a new lastEventId if the client capture method is not ca…
rxlabz Oct 16, 2020
97f6c53
feedbacks:
rxlabz Oct 16, 2020
e89c488
feedbacks:
rxlabz Oct 16, 2020
647f1b0
simplify the captureMessage API
rxlabz Oct 19, 2020
91f709a
capture message
rxlabz Oct 19, 2020
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
- hub capture exception
  • Loading branch information
rxlabz committed Oct 15, 2020
commit ea5c55faf44c748fb010eee7f90091923466cecd
5 changes: 0 additions & 5 deletions dart/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ Future<void> main(List<String> rawArgs) async {
final response = await Sentry.captureEvent(event);

print('SentryId : ${response.id}');
/*if (response.isSuccessful) {
print('SUCCESS\nid: ${response.eventId}');
} else {
print('FAILURE: ${response.error}');
}*/

try {
await foo();
Expand Down
45 changes: 39 additions & 6 deletions dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,46 @@ class Hub implements HubInterface {
}

@override
SentryId captureException({Message message, SeverityLevel level}) {
// TODO: implement captureException
throw UnimplementedError();
Future<SentryId> captureException(
{dynamic throwable, dynamic stackTrace}) async {
var sentryId = SentryId.empty();

if (!_isEnabled) {
_options.logger(
SeverityLevel.warning,
"Instance is disabled and this 'captureException' call is a no-op.",
);
} else if (throwable == null) {
_options.logger(
SeverityLevel.warning,
'captureException called with null parameter.',
);
} else {
final item = _stack.last;
if (item != null) {
try {
sentryId = await item.client
.captureException(exception: throwable, stackTrace: stackTrace);
} catch (err) {
_options.logger(
SeverityLevel.error,
'Error while capturing event with id: ${throwable}',
);
}
} else {
_options.logger(
SeverityLevel.fatal,
'Stack peek was null when captureException',
);
}
}
_lastEventId = sentryId;
return sentryId;
}

@override
SentryId captureMessage({Message message, SeverityLevel level}) {
Future<SentryId> captureMessage(
{Message message, SeverityLevel level}) async {
// TODO: implement captureMessage
throw UnimplementedError();
}
Expand Down Expand Up @@ -238,10 +271,10 @@ abstract class HubInterface {
Future<SentryId> captureEvent(Event event);

/// Captures the exception
SentryId captureException({Message message, SeverityLevel level});
Future<SentryId> captureException({dynamic throwable, dynamic stackTrace});

/// Captures the message.
SentryId captureMessage({Message message, SeverityLevel level});
Future<SentryId> captureMessage({Message message, SeverityLevel level});

/// Starts a new session. If there's a running session, it ends it before starting the new one.
void startSession();
Expand Down
4 changes: 2 additions & 2 deletions dart/lib/src/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class Sentry {
dynamic stackTrace,
}) async {
return _hub.captureException(
message: error,
//stackTrace: stackTrace,
throwable: error,
stackTrace: stackTrace,
);
}

Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/sentry_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ class SentryOptions {
}) : _logger = logger;
}

void defaultLogger({SeverityLevel level, String message}) {
void defaultLogger(SeverityLevel level, String message) {
print('[$level] $message');
}
27 changes: 24 additions & 3 deletions dart/test/sentry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void main() {

setUp(() {
Sentry.init((options) => options.dsn = fakeDns);
anException = Exception('anException');

client = MockSentryClient();
Sentry.initClient(client);
Expand All @@ -22,9 +23,29 @@ void main() {
verify(client.captureEvent(event: event)).called(1);
});

test('should capture the exception', () {
Sentry.captureException(anException);
verify(client.captureException(exception: anException)).called(1);
test('should not capture a null event', () async {
await Sentry.captureEvent(null);
verifyNever(client.captureEvent(event: event));
});

test('should not capture a null exception', () async {
await Sentry.captureException(null);
verifyNever(
client.captureException(
exception: anyNamed('exception'),
stackTrace: anyNamed('stackTrace'),
),
);
});

test('should capture the exception', () async {
await Sentry.captureException(anException);
verify(
client.captureException(
exception: anException,
stackTrace: null,
),
).called(1);
});
});
}
Expand Down