mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Plugins throw exceptions for startup errors
This commit is contained in:
@@ -9,6 +9,7 @@ import org.briarproject.bramble.api.keyagreement.KeyAgreementListener;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.Backoff;
|
||||
import org.briarproject.bramble.api.plugin.PluginException;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPluginCallback;
|
||||
@@ -99,7 +100,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() throws IOException {
|
||||
public void start() throws PluginException {
|
||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||
// Initialise the Bluetooth stack
|
||||
try {
|
||||
@@ -108,13 +109,14 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
// On Linux the user may need to install libbluetooth-dev
|
||||
if (OsUtils.isLinux())
|
||||
callback.showMessage("BLUETOOTH_INSTALL_LIBS");
|
||||
return false;
|
||||
throw new PluginException(e);
|
||||
} catch (BluetoothStateException e) {
|
||||
throw new PluginException(e);
|
||||
}
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Local address " + localDevice.getBluetoothAddress());
|
||||
running = true;
|
||||
bind();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void bind() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.briarproject.bramble.plugin.file;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.PluginException;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.plugin.simplex.SimplexPluginCallback;
|
||||
|
||||
@@ -42,17 +43,24 @@ class RemovableDrivePlugin extends FilePlugin
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() throws IOException {
|
||||
public void start() throws PluginException {
|
||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||
running = true;
|
||||
monitor.start(this);
|
||||
return true;
|
||||
try {
|
||||
monitor.start(this);
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws IOException {
|
||||
public void stop() throws PluginException {
|
||||
running = false;
|
||||
monitor.stop();
|
||||
try {
|
||||
monitor.stop();
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.briarproject.bramble.api.data.BdfList;
|
||||
import org.briarproject.bramble.api.keyagreement.KeyAgreementListener;
|
||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.PluginException;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.plugin.duplex.AbstractDuplexTransportConnection;
|
||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin;
|
||||
@@ -68,7 +69,7 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
public void start() throws PluginException {
|
||||
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||
for (String portName : serialPortList.getPortNames()) {
|
||||
if (LOG.isLoggable(INFO))
|
||||
@@ -79,12 +80,12 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Initialised modem on " + portName);
|
||||
running = true;
|
||||
return true;
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
throw new PluginException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user