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) {
|
} catch (CommandException e) {
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
if (verboseLevel > 0 && e.getCause() != null) {
|
if (verboseLevel > 0 && e.getCause() != null) {
|
||||||
e.getCause().printStackTrace();
|
e.getCause().printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
status = getStatusForError(e);
|
status = getStatusForError(e);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace(System.err);
|
||||||
status = 2;
|
status = 2;
|
||||||
}
|
}
|
||||||
System.exit(status);
|
System.exit(status);
|
||||||
|
|
|
@ -948,7 +948,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
};
|
};
|
||||||
connection.addSigHandler(Signal.SyncMessageReceivedV2.class, signal, this.dbusSyncHandler);
|
connection.addSigHandler(Signal.SyncMessageReceivedV2.class, signal, this.dbusSyncHandler);
|
||||||
} catch (DBusException e) {
|
} catch (DBusException e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
signal.subscribeReceive();
|
signal.subscribeReceive();
|
||||||
}
|
}
|
||||||
|
@ -968,7 +968,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
connection.removeSigHandler(Signal.ReceiptReceivedV2.class, signal, this.dbusRcptHandler);
|
connection.removeSigHandler(Signal.ReceiptReceivedV2.class, signal, this.dbusRcptHandler);
|
||||||
connection.removeSigHandler(Signal.SyncMessageReceivedV2.class, signal, this.dbusSyncHandler);
|
connection.removeSigHandler(Signal.SyncMessageReceivedV2.class, signal, this.dbusSyncHandler);
|
||||||
} catch (DBusException e) {
|
} catch (DBusException e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
|
||||||
try {
|
try {
|
||||||
sendDbusMessages(envelope);
|
sendDbusMessages(envelope);
|
||||||
} catch (DBusException e) {
|
} 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.RateLimitException;
|
||||||
import org.asamk.signal.manager.api.UserAlreadyExistsException;
|
import org.asamk.signal.manager.api.UserAlreadyExistsException;
|
||||||
import org.freedesktop.dbus.DBusPath;
|
import org.freedesktop.dbus.DBusPath;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -24,6 +26,7 @@ import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(DbusSignalControlImpl.class);
|
||||||
private final MultiAccountManager c;
|
private final MultiAccountManager c;
|
||||||
|
|
||||||
private final String objectPath;
|
private final String objectPath;
|
||||||
|
@ -101,20 +104,21 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String link(final String newDeviceName) throws Error.Failure {
|
public String link(final String newDeviceName) throws Error.Failure {
|
||||||
|
final URI deviceLinkUri;
|
||||||
try {
|
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(() -> {
|
Thread.ofPlatform().name("dbus-link").start(() -> {
|
||||||
final ProvisioningManager provisioningManager = c.getProvisioningManagerFor(deviceLinkUri);
|
final ProvisioningManager provisioningManager = c.getProvisioningManagerFor(deviceLinkUri);
|
||||||
try {
|
try {
|
||||||
provisioningManager.finishDeviceLink(newDeviceName);
|
provisioningManager.finishDeviceLink(newDeviceName);
|
||||||
} catch (IOException | TimeoutException | UserAlreadyExistsException e) {
|
} catch (IOException | TimeoutException | UserAlreadyExistsException e) {
|
||||||
e.printStackTrace();
|
logger.warn("Failed to finish linking", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return deviceLinkUri.toString();
|
return deviceLinkUri.toString();
|
||||||
} catch (TimeoutException | IOException e) {
|
|
||||||
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue