Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Unified Diff: mojo/dart/packages/mojo/lib/src/application_connection.dart

Issue 1819193003: Dart: Replace some asserts with exceptions (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/packages/mojo/lib/src/application_connection.dart
diff --git a/mojo/dart/packages/mojo/lib/src/application_connection.dart b/mojo/dart/packages/mojo/lib/src/application_connection.dart
index 41405e87e611090ce2bb84d86f0c2949d9fb978b..2ade88d90d7d76a320e5f310cb5ad86702cf9e05 100644
--- a/mojo/dart/packages/mojo/lib/src/application_connection.dart
+++ b/mojo/dart/packages/mojo/lib/src/application_connection.dart
@@ -13,7 +13,9 @@ class LocalServiceProvider implements ServiceProvider {
ServiceProviderStub _stub;
LocalServiceProvider(this.connection, this._stub) {
- assert(_stub.isOpen);
+ if (!_stub.isOpen) {
+ throw new core.MojoApiError("The service provider stub must be open");
+ }
_stub.impl = this;
}
@@ -78,18 +80,27 @@ class ApplicationConnection {
FallbackServiceFactory get fallbackServiceFactory => _fallbackServiceFactory;
set fallbackServiceFactory(FallbackServiceFactory f) {
- assert(_localServiceProvider != null);
+ if (_localServiceProvider == null) {
+ throw new core.MojoApiError(
+ "There must be a local service provider to set a service factory");
+ }
_fallbackServiceFactory = f;
}
bindings.ProxyBase requestService(bindings.ProxyBase proxy,
[String serviceName]) {
- assert(!proxy.impl.isBound &&
- (remoteServiceProvider != null) &&
- remoteServiceProvider.impl.isBound);
+ if (proxy.impl.isBound ||
+ (remoteServiceProvider == null) ||
+ !remoteServiceProvider.impl.isBound) {
+ throw new core.MojoApiError(
+ "The proxy is bound, or there is no remove service provider proxy");
+ }
var name = serviceName ?? proxy.serviceName;
- assert((name != null) && name.isNotEmpty);
+ if ((name == null) || name.isEmpty) {
+ throw new core.MojoApiError(
+ "If an interface has no ServiceName, then one must be provided.");
+ }
var pipe = new core.MojoMessagePipe();
proxy.impl.bind(pipe.endpoints[0]);
@@ -102,8 +113,15 @@ class ApplicationConnection {
/// choose to expose a service description.
void provideService(String interfaceName, ServiceFactory factory,
{service_describer.ServiceDescription description}) {
- assert(_localServiceProvider != null);
- assert(interfaceName != null);
+ if (_localServiceProvider == null) {
+ throw new core.MojoApiError(
+ "There must be a local service provider to provide a service");
+ }
+ if ((interfaceName == null) || interfaceName.isEmpty) {
+ throw new core.MojoApiError(
+ "The interface name must be non-null and non-empty");
+ }
+
_nameToServiceFactory[interfaceName] = factory;
if (description != null) {
_serviceDescriptions[interfaceName] = description;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698