Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- Ref: rename the `throwable` argument name to `exception` in `captureEvents(...)`
- Ref : remove dsn from Transport public Api
- update the Dart sdk constraint
- fix : throws on invalid dsn

# `package:sentry` changelog

Expand Down
2 changes: 0 additions & 2 deletions dart/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ Future<void> main() async {
} finally {
await Sentry.close();
}

/* TODO(rxlabz) Sentry CaptureMessage(message, level) */
}

Future<void> loadConfig() async {
Expand Down
14 changes: 5 additions & 9 deletions dart/lib/src/protocol/dsn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,11 @@ class Dsn {
final uri = Uri.parse(dsn);
final userInfo = uri.userInfo.split(':');

assert(() {
if (uri.pathSegments.isEmpty) {
throw ArgumentError(
'Project ID not found in the URI path of the DSN URI: $dsn',
);
}

return true;
}());
if (uri.pathSegments.isEmpty) {
throw ArgumentError(
'Project ID not found in the URI path of the DSN URI: $dsn',
);
}

return Dsn(
publicKey: userInfo[0],
Expand Down
8 changes: 7 additions & 1 deletion dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ abstract class SentryClient {
SentryClient.base(this._options, {String origin}) {
_random = _options.sampleRate == null ? null : Random();
if (_options.transport is NoOpTransport) {
_options.transport = HttpTransport(options: _options, origin: origin);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marandaneto shouldn't we catch the potential Dns.parse exception ? What do you think would be the best strategy or preferred wording here ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try {
_options.transport = HttpTransport(options: _options, origin: origin);
} on ArgumentError catch (error) {
_options.logger(SentryLevel.error, '${error.message}');
} catch (err) {
_options.logger(SentryLevel.error, 'An exception occurred.');
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/transport/http_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HttpTransport implements Transport {
_dsn = Dsn.parse(options.dsn),
_headers = _buildHeaders(sdkIdentifier: options.sdk.identifier) {
_credentialBuilder = CredentialBuilder(
dsn: Dsn.parse(options.dsn),
dsn: _dsn,
clientId: options.sdk.identifier,
clock: options.clock,
);
Expand Down