mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Reduce use of printStackTrace
This commit is contained in:
parent
4e8f0a41c7
commit
e61f587bfc
4 changed files with 19 additions and 15 deletions
|
@ -62,11 +62,11 @@ public class Main {
|
|||
} catch (CommandException e) {
|
||||
System.err.println(e.getMessage());
|
||||
if (verboseLevel > 0 && e.getCause() != null) {
|
||||
e.getCause().printStackTrace();
|
||||
e.getCause().printStackTrace(System.err);
|
||||
}
|
||||
status = getStatusForError(e);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace(System.err);
|
||||
status = 2;
|
||||
}
|
||||
System.exit(status);
|
||||
|
|
|
@ -948,7 +948,7 @@ public class DbusManagerImpl implements Manager {
|
|||
};
|
||||
connection.addSigHandler(Signal.SyncMessageReceivedV2.class, signal, this.dbusSyncHandler);
|
||||
} catch (DBusException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
signal.subscribeReceive();
|
||||
}
|
||||
|
@ -968,7 +968,7 @@ public class DbusManagerImpl implements Manager {
|
|||
connection.removeSigHandler(Signal.ReceiptReceivedV2.class, signal, this.dbusRcptHandler);
|
||||
connection.removeSigHandler(Signal.SyncMessageReceivedV2.class, signal, this.dbusSyncHandler);
|
||||
} catch (DBusException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
|
|||
try {
|
||||
sendDbusMessages(envelope);
|
||||
} catch (DBusException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.asamk.signal.manager.api.PinLockedException;
|
|||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.UserAlreadyExistsException;
|
||||
import org.freedesktop.dbus.DBusPath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
@ -24,6 +26,7 @@ import java.util.concurrent.TimeoutException;
|
|||
|
||||
public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(DbusSignalControlImpl.class);
|
||||
private final MultiAccountManager c;
|
||||
|
||||
private final String objectPath;
|
||||
|
@ -101,20 +104,21 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
|
||||
@Override
|
||||
public String link(final String newDeviceName) throws Error.Failure {
|
||||
final URI deviceLinkUri;
|
||||
try {
|
||||
final URI deviceLinkUri = c.getNewProvisioningDeviceLinkUri();
|
||||
deviceLinkUri = c.getNewProvisioningDeviceLinkUri();
|
||||
} catch (TimeoutException | IOException e) {
|
||||
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
|
||||
}
|
||||
Thread.ofPlatform().name("dbus-link").start(() -> {
|
||||
final ProvisioningManager provisioningManager = c.getProvisioningManagerFor(deviceLinkUri);
|
||||
try {
|
||||
provisioningManager.finishDeviceLink(newDeviceName);
|
||||
} catch (IOException | TimeoutException | UserAlreadyExistsException e) {
|
||||
e.printStackTrace();
|
||||
logger.warn("Failed to finish linking", e);
|
||||
}
|
||||
});
|
||||
return deviceLinkUri.toString();
|
||||
} catch (TimeoutException | IOException e) {
|
||||
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue