mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Handle UnsupportedOperationException in daemon command
This commit is contained in:
parent
69fe3986cf
commit
1ffb6d6907
1 changed files with 6 additions and 3 deletions
|
@ -10,6 +10,7 @@ import org.asamk.signal.ReceiveMessageHandler;
|
||||||
import org.asamk.signal.commands.exceptions.CommandException;
|
import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||||
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.dbus.DbusSignalControlImpl;
|
import org.asamk.signal.dbus.DbusSignalControlImpl;
|
||||||
import org.asamk.signal.dbus.DbusSignalImpl;
|
import org.asamk.signal.dbus.DbusSignalImpl;
|
||||||
import org.asamk.signal.json.JsonReceiveMessageHandler;
|
import org.asamk.signal.json.JsonReceiveMessageHandler;
|
||||||
|
@ -282,7 +283,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
||||||
|
|
||||||
private void runDbusSingleAccount(
|
private void runDbusSingleAccount(
|
||||||
final Manager m, final boolean isDbusSystem, final boolean noReceiveOnStart
|
final Manager m, final boolean isDbusSystem, final boolean noReceiveOnStart
|
||||||
) throws UnexpectedErrorException {
|
) throws CommandException {
|
||||||
runDbus(isDbusSystem, (conn, objectPath) -> {
|
runDbus(isDbusSystem, (conn, objectPath) -> {
|
||||||
try {
|
try {
|
||||||
exportDbusObject(conn, objectPath, m, noReceiveOnStart).join();
|
exportDbusObject(conn, objectPath, m, noReceiveOnStart).join();
|
||||||
|
@ -293,7 +294,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
||||||
|
|
||||||
private void runDbusMultiAccount(
|
private void runDbusMultiAccount(
|
||||||
final MultiAccountManager c, final boolean noReceiveOnStart, final boolean isDbusSystem
|
final MultiAccountManager c, final boolean noReceiveOnStart, final boolean isDbusSystem
|
||||||
) throws UnexpectedErrorException {
|
) throws CommandException {
|
||||||
runDbus(isDbusSystem, (connection, objectPath) -> {
|
runDbus(isDbusSystem, (connection, objectPath) -> {
|
||||||
final var signalControl = new DbusSignalControlImpl(c, objectPath);
|
final var signalControl = new DbusSignalControlImpl(c, objectPath);
|
||||||
connection.exportObject(signalControl);
|
connection.exportObject(signalControl);
|
||||||
|
@ -332,7 +333,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
||||||
|
|
||||||
private void runDbus(
|
private void runDbus(
|
||||||
final boolean isDbusSystem, DbusRunner dbusRunner
|
final boolean isDbusSystem, DbusRunner dbusRunner
|
||||||
) throws UnexpectedErrorException {
|
) throws CommandException {
|
||||||
DBusConnection.DBusBusType busType;
|
DBusConnection.DBusBusType busType;
|
||||||
if (isDbusSystem) {
|
if (isDbusSystem) {
|
||||||
busType = DBusConnection.DBusBusType.SYSTEM;
|
busType = DBusConnection.DBusBusType.SYSTEM;
|
||||||
|
@ -345,6 +346,8 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
||||||
dbusRunner.run(conn, DbusConfig.getObjectPath());
|
dbusRunner.run(conn, DbusConfig.getObjectPath());
|
||||||
} catch (DBusException e) {
|
} catch (DBusException e) {
|
||||||
throw new UnexpectedErrorException("Dbus command failed: " + e.getMessage(), e);
|
throw new UnexpectedErrorException("Dbus command failed: " + e.getMessage(), e);
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
throw new UserErrorException("Failed to connect to Dbus: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue